This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Allow the user to logout with a malformed or expired token [#1257] #1305
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pattisdr
changed the title
[DRAFT] Allow the user to logout with a malformed or expired token [#1257]
Allow the user to logout with a malformed or expired token [#1257]
Sep 13, 2022
…ed instead of a 500.
I still got the error when logging out with the root user. I wonder if this one is specific to root user. It is using the root client, could logging out be trying to delete the root client and causing and error because of that? Either that or with the root user there is no user in the database, could that be throwing things off? Logs from the server: fidesops-webserver-1 | ERROR:uvicorn.error:Exception in ASGI application
fidesops-webserver-1 | Traceback (most recent call last):
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 372, in run_asgi
fidesops-webserver-1 | result = await app(self.scope, self.receive, self.send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
fidesops-webserver-1 | return await self.app(scope, receive, send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/message_logger.py", line 82, in __call__
fidesops-webserver-1 | raise exc from None
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/message_logger.py", line 78, in __call__
fidesops-webserver-1 | await self.app(scope, inner_receive, inner_send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 269, in __call__
fidesops-webserver-1 | await super().__call__(scope, receive, send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 124, in __call__
fidesops-webserver-1 | await self.middleware_stack(scope, receive, send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
fidesops-webserver-1 | raise exc
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
fidesops-webserver-1 | await self.app(scope, receive, _send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 68, in __call__
fidesops-webserver-1 | response = await self.dispatch_func(request, call_next)
fidesops-webserver-1 | File "/fidesops/src/fidesops/main.py", line 80, in dispatch_log_request
fidesops-webserver-1 | response = await call_next(request)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 46, in call_next
fidesops-webserver-1 | raise app_exc
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 36, in coro
fidesops-webserver-1 | await self.app(scope, request.receive, send_stream.send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 92, in __call__
fidesops-webserver-1 | await self.simple_response(scope, receive, send, request_headers=headers)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 147, in simple_response
fidesops-webserver-1 | await self.app(scope, receive, send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/exceptions.py", line 93, in __call__
fidesops-webserver-1 | raise exc
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
fidesops-webserver-1 | await self.app(scope, receive, sender)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
fidesops-webserver-1 | raise e
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
fidesops-webserver-1 | await self.app(scope, receive, send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 670, in __call__
fidesops-webserver-1 | await route.handle(scope, receive, send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 266, in handle
fidesops-webserver-1 | await self.app(scope, receive, send)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 65, in app
fidesops-webserver-1 | response = await func(request)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 231, in app
fidesops-webserver-1 | raw_response = await run_endpoint_function(
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 162, in run_endpoint_function
fidesops-webserver-1 | return await run_in_threadpool(dependant.call, **values)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
fidesops-webserver-1 | return await anyio.to_thread.run_sync(func, *args)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/anyio/to_thread.py", line 31, in run_sync
fidesops-webserver-1 | return await get_asynclib().run_sync_in_worker_thread(
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
fidesops-webserver-1 | return await future
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 867, in run
fidesops-webserver-1 | result = context.run(func, *args)
fidesops-webserver-1 | File "/fidesops/src/fidesops/ops/api/v1/endpoints/user_endpoints.py", line 160, in user_logout
fidesops-webserver-1 | client.delete(db)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/fideslib/db/base_class.py", line 259, in delete
fidesops-webserver-1 | db.delete(self)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2575, in delete
fidesops-webserver-1 | self._delete_impl(state, instance, head=True)
fidesops-webserver-1 | File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2581, in _delete_impl
fidesops-webserver-1 | raise sa_exc.InvalidRequestError(
fidesops-webserver-1 | sqlalchemy.exc.InvalidRequestError: Instance '<ClientDetail at 0x7f057050f2e0>' is not persisted |
Great callout @sanders41 - I hadn't tested against the root user. |
sanders41
approved these changes
Sep 14, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on getting this fixed, it had been causing lots of people issues.
sanders41
pushed a commit
that referenced
this pull request
Sep 22, 2022
…1305) * Allow the user to logout with a malformed or expired token. * Fix formatting. * Fix test comment. * Update changelog. * Bump fideslib version to raise a 403 if the supplied token is malformed instead of a 500. * Allow the root user to logout.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Whenever the user logs out from the Admin UI, the local auth token should be deleted no matter what happens on the server (403, 500, etc.). This would prevent you from getting into an unrecoverable state where you cannot clear your token
Changes
logout_oauth_client
instead of using theverify_oauth_client
from fideslib:Testing
See testing instructions in #1257
Checklist
CHANGELOG.md
fileCHANGELOG.md
file is being appended toUnreleased
section in an appropriate category. Add a new category from the list at the top of the file if the needed one isn't already there.Run Unsafe PR Checks
label has been applied, and checks have passed, if this PR touches any external servicesTicket
Fixes #1257