Repository navigation
fix: make auth logout() best-effort and never fail local logout - #58
Merged
Merged
Conversation
Revoking the login session remotely could raise (e.g. 404 'No session ID in client' when the client's auth service session cookie was lost across app workers or swept server-side), which turned /logout into a 500 for the whole app. Logout must always succeed locally: clear flask.g and the stored login session id, attempt remote revocation, and log a warning if it fails.
This was referenced Oct 1, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes the server-side half of nyjc-computing/campus-admin#14:
GET /logout500 (NotFoundError: No session ID in client).What happened
The auth service's
DELETE /auth/v1/logins/<id>requires the client's own{provider}_session_idcookie (_verify_session_idincampus/auth/resources/login.py), returning 404 "No session ID in client" when absent. TheCampusclient keeps its cookie jar in a per-processrequests.Session, so with multi-worker gunicorn (or after any deploy/restart) the login POST and the logout DELETE can hit different processes — the cookie is gone, the DELETE 404s, andraise_for_status()blew up the app's/logoutroute.Fix
AuthAPI.logout()now treats remote revocation as best-effort:flask.g.pop(..., None)so a directlogout()outside the usual request flow cannot KeyError.Apps always get a local logout + redirect, matching the expectation recorded in campus-admin#14. Verified locally against the dev auth service: a Flask session with a stale
logins_login_id(and a dummy client) now logs out cleanly with a warning instead of raising.The auth-service side (DELETE /logins rejecting server-to-server clients whose per-process cookie jar lost the auth session) deserves a separate look; I'll file that on the campus repo.