Skip to content

Commit fd43e7f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent c2b9ea5 commit fd43e7f

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

oauth2_provider/models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,10 @@ def redirect_to_uri_allowed(uri, allowed_uris):
808808
# time of the request for loopback IP redirect URIs, to accommodate
809809
# clients that obtain an available ephemeral port from the operating
810810
# system at the time of the request.
811-
allowed_uri_is_loopback = (parsed_allowed_uri.scheme == "http" and parsed_allowed_uri.hostname in ["127.0.0.1", "::1"])
811+
allowed_uri_is_loopback = parsed_allowed_uri.scheme == "http" and parsed_allowed_uri.hostname in [
812+
"127.0.0.1",
813+
"::1",
814+
]
812815
""" check port """
813816
if not allowed_uri_is_loopback and parsed_allowed_uri.port != parsed_uri.port:
814817
continue
@@ -824,7 +827,8 @@ def redirect_to_uri_allowed(uri, allowed_uris):
824827
""" check querystring """
825828
aqs_set = set(parse_qsl(parsed_allowed_uri.query))
826829
if not aqs_set.issubset(uqs_set):
827-
continue # circuit break
830+
continue # circuit break
831+
828832

829833
def is_origin_allowed(origin, allowed_origins):
830834
"""

oauth2_provider/validators.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,31 @@ def __call__(self, value):
8282
if self.allow_hostname_wildcard and "*" in netloc:
8383
domain_parts = netloc.split(".")
8484
if netloc.count("*") > 1:
85-
raise ValidationError(
86-
"%(name)s URI validation error. %(cause)s: %(value)s",
87-
params={"name": self.name, "value": value, "cause": "only one wildcard is allowed in the hostname"},
88-
)
85+
raise ValidationError(
86+
"%(name)s URI validation error. %(cause)s: %(value)s",
87+
params={
88+
"name": self.name,
89+
"value": value,
90+
"cause": "only one wildcard is allowed in the hostname",
91+
},
92+
)
8993
if not netloc.startswith("*"):
9094
raise ValidationError(
9195
"%(name)s URI validation error. %(cause)s: %(value)s",
92-
params={"name": self.name, "value": value, "cause": "wildcards must be at the beginning of the hostname"},
96+
params={
97+
"name": self.name,
98+
"value": value,
99+
"cause": "wildcards must be at the beginning of the hostname",
100+
},
93101
)
94102
if len(domain_parts) < 3:
95103
raise ValidationError(
96104
"%(name)s URI validation error. %(cause)s: %(value)s",
97-
params={"name": self.name, "value": value, "cause": "wildcards cannot be in the top level or second level domain"},
105+
params={
106+
"name": self.name,
107+
"value": value,
108+
"cause": "wildcards cannot be in the top level or second level domain",
109+
},
98110
)
99111

100112
# strip the wildcard from the netloc, we'll reassamble the value later to pass to URI Validator
@@ -107,12 +119,20 @@ def __call__(self, value):
107119
if path.count("*") > 1:
108120
raise ValidationError(
109121
"%(name)s URI validation error. %(cause)s: %(value)s",
110-
params={"name": self.name, "value": value, "cause": "only one wildcard is allowed in the path"},
122+
params={
123+
"name": self.name,
124+
"value": value,
125+
"cause": "only one wildcard is allowed in the path",
126+
},
111127
)
112128
if not path.endswith("*"):
113129
raise ValidationError(
114130
"%(name)s URI validation error. %(cause)s: %(value)s",
115-
params={"name": self.name, "value": value, "cause": "wildcards must be at the end of the path"},
131+
params={
132+
"name": self.name,
133+
"value": value,
134+
"cause": "wildcards must be at the end of the path",
135+
},
116136
)
117137
# strip the wildcard from the path, we'll reassamble the value later to pass to URI Validator
118138
path = path[:-1]

0 commit comments

Comments
 (0)