Skip to content

Commit 6aa1da2

Browse files
Tuhin-thinksn2ygk
authored andcommitted
fixed: Handled error when authheader is Bearer with no token-string following up.
1 parent 937ae21 commit 6aa1da2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

oauth2_provider/middleware.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def __init__(self, get_response):
5252

5353
def __call__(self, request):
5454
authheader = request.META.get("HTTP_AUTHORIZATION", "")
55-
if authheader.startswith("Bearer"):
56-
tokenstring = authheader.split()[1]
55+
if authheader.startswith("Bearer") and len(authheader.split(maxsplit=1)) == 2:
56+
tokenstring = authheader.split(maxsplit=1)[1]
5757
AccessToken = get_access_token_model()
5858
try:
5959
token_checksum = hashlib.sha256(tokenstring.encode("utf-8")).hexdigest()

0 commit comments

Comments
 (0)