Skip to content

Commit 39a2a4e

Browse files
committed
Add allow_fragments argument to RedirectURIValidator
1 parent fe89a35 commit 39a2a4e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

oauth2_provider/validators.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@ class URIValidator(URLValidator):
2525

2626

2727
class RedirectURIValidator(URIValidator):
28-
def __init__(self, allowed_schemes):
28+
def __init__(self, allowed_schemes, allow_fragments=False):
2929
super().__init__(schemes=allowed_schemes)
30+
self.allow_fragments = allow_fragments
3031

3132
def __call__(self, value):
3233
super().__call__(value)
3334
value = force_text(value)
34-
if len(value.split("#")) > 1:
35-
raise ValidationError("Redirect URIs must not contain fragments")
3635
scheme, netloc, path, query, fragment = urlsplit(value)
36+
if fragment and not self.allow_fragments:
37+
raise ValidationError("Redirect URIs must not contain fragments")
3738
if scheme.lower() not in self.schemes:
3839
raise ValidationError("Redirect URI scheme is not allowed.")
3940

0 commit comments

Comments
 (0)