1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import re
from flask_wtf import FlaskForm
from wtforms import PasswordField, StringField, SubmitField
from wtforms.validators import URL, InputRequired, Regexp
from .validators import AllowedHostname, NotEqualTo, PublicURL
class LoginForm(FlaskForm):
username = StringField("Username", validators=[InputRequired()])
password = PasswordField("Password", validators=[InputRequired()])
submit = SubmitField("Sign In")
class EndpointForm(FlaskForm):
source = StringField(
"source",
validators=[
InputRequired(),
URL(),
Regexp(
"^https?://.*",
flags=re.IGNORECASE,
message="source must begin with http or https",
),
NotEqualTo("target"),
PublicURL(),
],
)
target = StringField(
"target",
validators=[
InputRequired(),
URL(),
Regexp(
"^https?://.*",
flags=re.IGNORECASE,
message="target must begin with http or https",
),
AllowedHostname(),
],
)
|