Skip to content

Add consent screen for OAuth authorization#75

Merged
1 commit merged into
mainfrom
feat/consent-screen
Apr 3, 2026
Merged

Add consent screen for OAuth authorization#75
1 commit merged into
mainfrom
feat/consent-screen

Conversation

@eswan18
Copy link
Copy Markdown
Owner

@eswan18 eswan18 commented Mar 31, 2026

Summary

Adds a consent screen to the OAuth authorization flow. Users now see the client application name and requested permissions (with human-readable descriptions) before granting access, with Allow and Deny buttons.

  • Consent is remembered per user+client in a new oauth_user_consents table. Users are only re-prompted when a client requests scopes not previously consented to.
  • Deny redirects to the client with error=access_denied per RFC 6749 4.1.2.1.
  • login.go and mfa.go refactored to redirect back to /oauth/authorize after establishing a session, instead of generating auth codes directly. This centralizes all consent + code generation logic in one place.

Scope descriptions shown to users

Scope Description
openid Verify your identity
profile View your profile information (name, username, avatar)
email View your email address

Migration

Migration 000009 adds the oauth_user_consents table. Must be run before deploying.

Test plan

5 new consent-specific tests (written red/green TDD):

  • TestConsentScreenShownOnFirstAuthorize — redirects to /oauth/consent instead of straight to client
  • TestConsentApproveGeneratesCode — approving consent generates auth code
  • TestConsentDenyRedirectsWithError — denying returns error=access_denied
  • TestConsentRemembered — second authorize with same scopes skips consent
  • TestConsentRePromptedForNewScopes — requesting new scopes shows consent again

All 109 tests pass (existing tests updated to handle consent step).

Closes #64.

🤖 Generated with Claude Code

Users now see a consent page showing the client name and requested
permissions before granting access. This addresses a trust and
transparency gap — previously, authenticated users were silently
redirected to clients with an authorization code and no opportunity
to review or deny the request.

Key changes:

- New `oauth_user_consents` table stores per-user, per-client consent
  with granted scopes. Consent is remembered so users aren't re-prompted
  unless the client requests new scopes.

- New consent page (`/oauth/consent`) using existing DaisyUI card pattern,
  showing the client name and human-readable scope descriptions with
  Allow/Deny buttons.

- Deny redirects to client with `error=access_denied` per RFC 6749.

- HandleOauthAuthorize now checks stored consent before generating an
  authorization code. If consent is missing or doesn't cover the
  requested scopes, the user is redirected to the consent page.

- login.go and mfa.go refactored to redirect back to /oauth/authorize
  after establishing a session, instead of generating auth codes
  directly. This centralizes all consent + code generation logic.

- All existing tests updated to handle the new consent step. Added
  mustLoginAndConsent helper for inline OAuth flows.

Closes #64.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eswan18 eswan18 closed this pull request by merging all changes into main in 3953855 Apr 3, 2026
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.

Add consent screen showing requested scopes before authorization

1 participant