Skip to content

Require auth on success page; distinguish DB errors in introspection#73

Merged
eswan18 merged 1 commit into
mainfrom
fix/success-auth-and-introspect-errors
Mar 31, 2026
Merged

Require auth on success page; distinguish DB errors in introspection#73
eswan18 merged 1 commit into
mainfrom
fix/success-auth-and-introspect-errors

Conversation

@eswan18

@eswan18 eswan18 commented Mar 31, 2026

Copy link
Copy Markdown
Owner

Summary

Two small bug fixes:

  • Success page auth check (Verify user authentication on success page #68): HandleSuccess now verifies the user has a valid session before rendering. Previously, anyone could visit /oauth/success directly 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): introspectAccessToken now distinguishes sql.ErrNoRows (token not found — expected, returns {"active": false}) from other database errors (unexpected — returns 500 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/success returns 302 to /oauth/login (written red/green TDD)
  • TestSuccessPageRendersWhenAuthenticated — authenticated GET returns 200
  • Introspection DB error: not practical to integration-test a DB failure, but the fix follows the same sql.ErrNoRows pattern already validated in the UserInfo handler. All existing introspection tests pass.
  • Full regression: all 60+ tests pass

Closes #68, closes #69.

🤖 Generated with Claude Code

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>
@eswan18 eswan18 merged commit 9069d62 into main Mar 31, 2026
1 check passed
@eswan18 eswan18 deleted the fix/success-auth-and-introspect-errors branch March 31, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle database errors distinctly from 'not found' in token introspection Verify user authentication on success page

1 participant