Require auth on success page; distinguish DB errors in introspection#73
Merged
Merged
Conversation
Two small fixes: 1. HandleSuccess now checks for a valid session before rendering, redirecting to /oauth/login if unauthenticated. Previously anyone could visit /oauth/success directly. (Closes #68) 2. introspectAccessToken now distinguishes sql.ErrNoRows (token not found, expected) from other database errors. On a real DB error, HandleIntrospect returns 500 server_error instead of silently reporting the token as inactive. This prevents a DB outage from being masked as "all tokens inactive". (Closes #69) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Two small bug fixes:
Success page auth check (Verify user authentication on success page #68):
HandleSuccessnow verifies the user has a valid session before rendering. Previously, anyone could visit/oauth/successdirectly and see the page. Now unauthenticated users are redirected to/oauth/login.Introspection DB error handling (Handle database errors distinctly from 'not found' in token introspection #69):
introspectAccessTokennow distinguishessql.ErrNoRows(token not found — expected, returns{"active": false}) from other database errors (unexpected — returns500 server_error). Previously, a database outage would silently report all tokens as inactive, potentially causing cascading failures in client applications relying on introspection. This matches the pattern already used in the UserInfo endpoint.Test plan
TestSuccessPageRequiresAuthentication— unauthenticated GET to/oauth/successreturns 302 to/oauth/login(written red/green TDD)TestSuccessPageRendersWhenAuthenticated— authenticated GET returns 200sql.ErrNoRowspattern already validated in the UserInfo handler. All existing introspection tests pass.Closes #68, closes #69.
🤖 Generated with Claude Code