chronhq / backend

Backend for database. Python, Django, PostGIS
https://maps.chron.ist/
GNU General Public License v3.0
6 stars 1 forks source link

Use 401 (Unauthorized) for stale JWT token #200

Closed MiklerGM closed 4 years ago

MiklerGM commented 4 years ago

web_1      | 0 static files copied to '/src/static', 245 unmodified.
web_1      | [2020-01-26 15:39:22 +0000] [1] [INFO] Starting gunicorn 19.7.1
web_1      | [2020-01-26 15:39:22 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
web_1      | [2020-01-26 15:39:22 +0000] [1] [INFO] Using worker: sync
web_1      | /usr/local/lib/python3.8/os.py:1021: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
web_1      |   return io.open(fd, *args, **kwargs)
web_1      | [2020-01-26 15:39:22 +0000] [32] [INFO] Booting worker with pid: 32
web_1      | Internal Server Error: /api/spacetime-volumes/
web_1      | Traceback (most recent call last):
web_1      |   File "/opt/python/lib/python3.8/site-packages/firebase_admin/_token_gen.py", line 328, in verify
web_1      |     verified_claims = google.oauth2.id_token.verify_token(
web_1      |   File "/opt/python/lib/python3.8/site-packages/google/oauth2/id_token.py", line 123, in verify_token
web_1      |     return jwt.decode(id_token, certs=certs, audience=audience)
web_1      |   File "/opt/python/lib/python3.8/site-packages/google/auth/jwt.py", line 235, in decode
web_1      |     _verify_iat_and_exp(payload)
web_1      |   File "/opt/python/lib/python3.8/site-packages/google/auth/jwt.py", line 186, in _verify_iat_and_exp
web_1      |     raise ValueError("Token expired, {} < {}".format(latest, now))
web_1      | ValueError: Token expired, 1580047340 < 1580053167
web_1      | 
web_1      | During handling of the above exception, another exception occurred:
web_1      | 
web_1      | Traceback (most recent call last):
web_1      |   File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 118, in decode_token
web_1      |     return firebase_auth.verify_id_token(
web_1      |   File "/opt/python/lib/python3.8/site-packages/firebase_admin/auth.py", line 179, in verify_id_token
web_1      |     verified_claims = token_verifier.verify_id_token(id_token)
web_1      |   File "/opt/python/lib/python3.8/site-packages/firebase_admin/_token_gen.py", line 234, in verify_id_token
web_1      |     return self.id_token_verifier.verify(id_token, self.request)
web_1      |   File "/opt/python/lib/python3.8/site-packages/firebase_admin/_token_gen.py", line 339, in verify
web_1      |     raise self._expired_token_error(str(error), cause=error)
web_1      | firebase_admin._token_gen.ExpiredIdTokenError: Token expired, 1580047340 < 1580053167
web_1      | 
web_1      | During handling of the above exception, another exception occurred:
web_1      | 
web_1      | Traceback (most recent call last):
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 74, in wrap_attributeerrors
web_1      |     yield
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
web_1      |     self._authenticate()
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 373, in _authenticate
web_1      |     user_auth_tuple = authenticator.authenticate(self)
web_1      |   File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 57, in authenticate
web_1      |     decoded_token = self.decode_token(firebase_token)
web_1      |   File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 127, in decode_token
web_1      |     except firebase_auth.AuthError as exc:
web_1      | AttributeError: module 'firebase_admin.auth' has no attribute 'AuthError'
web_1      | 
web_1      | During handling of the above exception, another exception occurred:
web_1      | 
web_1      | Traceback (most recent call last):
web_1      |   File "/opt/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
web_1      |     response = get_response(request)
web_1      |   File "/opt/python/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
web_1      |     response = self.process_exception_by_middleware(e, request)
web_1      |   File "/opt/python/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
web_1      |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1      |   File "/opt/python/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
web_1      |     return view_func(*args, **kwargs)
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/viewsets.py", line 114, in view
web_1      |     return self.dispatch(request, *args, **kwargs)
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 505, in dispatch
web_1      |     response = self.handle_exception(exc)
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 465, in handle_exception
web_1      |     self.raise_uncaught_exception(exc)
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
web_1      |     raise exc
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 493, in dispatch
web_1      |     self.initial(request, *args, **kwargs)
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 410, in initial
web_1      |     self.perform_authentication(request)
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 324, in perform_authentication
web_1      |     request.user
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
web_1      |     self._authenticate()
web_1      |   File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
web_1      |     self.gen.throw(type, value, traceback)
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 78, in wrap_attributeerrors
web_1      |     raise exc.with_traceback(info[2])
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 74, in wrap_attributeerrors
web_1      |     yield
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
web_1      |     self._authenticate()
web_1      |   File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 373, in _authenticate
web_1      |     user_auth_tuple = authenticator.authenticate(self)
web_1      |   File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 57, in authenticate
web_1      |     decoded_token = self.decode_token(firebase_token)
web_1      |   File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 127, in decode_token
web_1      |     except firebase_auth.AuthError as exc:
web_1      | rest_framework.request.WrappedAttributeError: module 'firebase_admin.auth' has no attribute 'AuthError'