Features: 1) Log detailed traceback for unexpected authentication errors.
Fixes: 1) Handle generic exceptions during user authentication. Extra: 1) Add `traceback` import for logging exceptions.
This commit is contained in:
parent
43ece8c25c
commit
1630288e2e
1 changed files with 5 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import traceback
|
||||
from os import getenv
|
||||
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
|
|
@ -60,6 +61,10 @@ class GrapheneJWTAuthorizationMiddleware:
|
|||
user = AnonymousUser()
|
||||
except TypeError:
|
||||
user = AnonymousUser()
|
||||
except Exception as e:
|
||||
logger.warning("Could not authenticate user: %s", str(e))
|
||||
logger.debug(traceback.format_exc())
|
||||
user = AnonymousUser()
|
||||
return user
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue