Skip to content

Commit

Permalink
fixed: Handled error when authheader is Bearer with no token-strin…
Browse files Browse the repository at this point in the history
…g following up.
  • Loading branch information
Tuhin-thinks authored and n2ygk committed Sep 22, 2024
1 parent 937ae21 commit 6aa1da2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions oauth2_provider/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def __init__(self, get_response):

def __call__(self, request):
authheader = request.META.get("HTTP_AUTHORIZATION", "")
if authheader.startswith("Bearer"):
tokenstring = authheader.split()[1]
if authheader.startswith("Bearer") and len(authheader.split(maxsplit=1)) == 2:
tokenstring = authheader.split(maxsplit=1)[1]
AccessToken = get_access_token_model()
try:
token_checksum = hashlib.sha256(tokenstring.encode("utf-8")).hexdigest()
Expand Down

0 comments on commit 6aa1da2

Please sign in to comment.