Skip to content

feat: drop implicit & hybrid oauth2 response types - #3199

Merged
tada5hi merged 1 commit into
masterfrom
feat/oauth2-drop-implicit
Jul 8, 2026
Merged

tada5hi merged 1 commit into
masterfrom
feat/oauth2-drop-implicit

Conversation

@tada5hi

@tada5hi tada5hi commented Jul 8, 2026 •

Copy link
Copy Markdown
Collaborator

Plan 042 item 3. Decided with the plan: fix the "implicit tokens land in the redirect query string" defect (RFC 6749 §4.2.2 requires the fragment) at the source — by dropping the implicit/hybrid response types entirely, per the OAuth 2.1 draft (which removes the implicit grant) and RFC 9700 (OAuth 2.0 Security BCP: implicit MUST NOT be used).

What changes

  • response_type=code is the only supported response type. The code-request validator rejects token, id_token, none, and any hybrid combination; OAuth2Authorization.authorize() enforces the same as defense in depth (unsupported_response_type).
  • The authorization response never carries tokens. confirm() loses its access_token/id_token searchParams writes — previously those tokens leaked via browser history, proxy/access logs, and Referer (compounding the id_token-hint replay surface, see feat: validate & harden the rp-initiated logout endpoint (plan 042) #3198). An openid-scoped code still mints its id_token onto the code blob (with c_hash); the /token exchange returns it — unchanged.
  • Discovery response_types_supported now advertises only code (previously code, token, none).
  • Verifier tightened: PKCE + state for public clients are now unconditional — the willIssueCode gate is dead code with a code-only pipeline (every call site is validator-guarded, including the identity-provider flow, which validates the embedded code request before verifying).
  • OAuth2AuthorizationResult loses accessToken/idToken; the now-unused accessTokenIssuer was removed from the authorize controller/authorization contexts and wiring.
  • client-web's client URL generator page now emits response_type=code.

Error surface

At the HTTP layer a dropped response type yields the standard 400 validation shape (a response_type issue carrying the unsupported_response_type message) — consistent with how every other invalid /authorize parameter has always behaved. The precise OAuth2 error object is thrown by the core module (unit-tested). A spec-conformant error redirect back to the RP is deliberately not part of this PR — that redirect infrastructure lands with the prompt=none work (plan 042 item 10).

Tests

  • unit: rejection matrix (token, id_token, none, code token, id_token token) + code-issuance assertion in authorization/module.spec.ts (spec reworked onto response_type=code with a working code-issuer stub)
  • unit: verifier spec's "implicit flow skips state" test flipped to a rejection pin
  • e2e: authorize.spec.ts rewritten — code flow still works, each dropped type 400s with a response_type issue, and discovery advertises only code

Full server-core suite green (1163 tests; the known pre-existing grant-authorize FK flake documented in #3198 surfaced once across four runs, on an untouched code path).

BREAKING: any third-party RP using the implicit or hybrid flow against authup must migrate to the authorization code flow with PKCE. Authup's own kit, client-web, SSR pages, and federated IdP flow have always used the code flow — no first-party impact.

Summary by CodeRabbit

  • New Features

    • OAuth sign-in now uses authorization code flow only, with updated client links and discovery metadata to reflect the supported response type.
    • Public clients must always use PKCE and provide a state value.
  • Bug Fixes

    • Redirects no longer include access or ID tokens.
    • Unsupported or implicit/hybrid response types are now rejected consistently.

response_type=code is now the only supported response type (OAuth 2.1 /
RFC 9700 posture):

- the code-request validator requires response_type to be exactly
  'code'; token / id_token / none / hybrid combos are rejected
- OAuth2Authorization.authorize() is code-only (defense in depth) —
  the TOKEN/ID_TOKEN issuance branches, at_hash computation and the
  authorize-response accessToken/idToken outputs are gone; an
  openid-scoped code still carries its id_token on the code blob for
  the /token exchange
- AuthorizeController.confirm() no longer writes access_token /
  id_token into the redirect URL (tokens leaked via history, proxy
  logs and Referer - the fix at source is to not produce them at all)
- discovery response_types_supported now advertises only 'code'
- the code-request verifier requires PKCE + state for public clients
  unconditionally (the willIssueCode gate is dead with code-only)
- client-web's client URL generator emits response_type=code

BREAKING: RPs using the implicit or hybrid flow must migrate to the
authorization code flow with PKCE.
Copilot AI review requested due to automatic review settings July 8, 2026 09:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR restricts OAuth2/OIDC authorization to response_type=code only, rejecting implicit/hybrid types (token, id_token, none). It removes access-token/id-token issuance from the authorize flow, enforces PKCE and state unconditionally for public clients, updates discovery metadata, controller wiring, tests, and documentation.

Changes

Authorization-code-only flow

Layer / File(s) Summary
Response-type validation and code-only authorization core
apps/server-core/src/core/oauth2/authorization/code-request/validator.ts, apps/server-core/src/core/oauth2/authorization/module.ts, apps/server-core/src/core/oauth2/authorization/types.ts
Validator now requires exactly one code token; OAuth2Authorization.authorize() rejects non-code response types, always issues an authorization code, conditionally issues an id_token for openid scope using c_hash, and drops accessToken/idToken/accessTokenIssuer from types and class members.
Public client PKCE/state enforcement
apps/server-core/src/core/oauth2/authorization/code-request/verifier/module.ts
Removes willIssueCode gating; PKCE (code_challenge) and state are now required unconditionally for non-confidential clients.
Authorize controller wiring without accessTokenIssuer
apps/server-core/src/adapters/http/controllers/workflows/authorize/module.ts, .../authorize/types.ts, apps/server-core/src/app/modules/http/modules/controller.ts
Removes accessTokenIssuer from context, constructor, and DI resolution; redirect no longer includes access_token/id_token query parameters.
Discovery metadata and client-web authorize URL
apps/server-core/src/adapters/http/controllers/entities/realm/module.ts, apps/client-web/pages/clients/[id]/url.vue
Discovery response_types_supported reduced to [CODE]; client-web generated authorize URL now uses response_type=code.
Unit tests for code-only enforcement
apps/server-core/test/unit/core/oauth2/authorization/code-request/verifier/module.spec.ts, .../authorization/module.spec.ts, apps/server-core/test/unit/http/controllers/workflows/authorize.spec.ts
Adds/updates tests asserting PKCE required for public clients, rejection of non-code response types, and discovery advertising only CODE.
Architecture and API documentation updates
.agents/architecture.md, docs/src/guide/development/api-oauth2.md
Documents the codes-only posture, rejection of implicit/hybrid flows, and unconditional PKCE/state requirements for public clients.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • authup/authup#2937: Both PRs shift the authorization experience to an authorization-code-only flow by removing server-side token delivery in redirects.
  • authup/authup#3020: Both PRs modify the authorization-code verifier to enforce PKCE/state for public clients.
  • authup/authup#3054: Both PRs touch OAuth2 response_type handling/validation and the OAuth2ResponseTypeError.unsupported() error path.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: removing implicit and hybrid OAuth2 response types.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/oauth2-drop-implicit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jul 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

authup

npm i https://pkg.pr.new/authup@3199

@authup/client-web

npm i https://pkg.pr.new/@authup/client-web@3199

@authup/server-core

npm i https://pkg.pr.new/@authup/server-core@3199

@authup/access

npm i https://pkg.pr.new/@authup/access@3199

@authup/client-web-kit

npm i https://pkg.pr.new/@authup/client-web-kit@3199

@authup/client-web-kit-theme

npm i https://pkg.pr.new/@authup/client-web-kit-theme@3199

@authup/client-web-nuxt

npm i https://pkg.pr.new/@authup/client-web-nuxt@3199

@authup/client-web-theme

npm i https://pkg.pr.new/@authup/client-web-theme@3199

@authup/core-http-kit

npm i https://pkg.pr.new/@authup/core-http-kit@3199

@authup/core-kit

npm i https://pkg.pr.new/@authup/core-kit@3199

@authup/core-realtime-kit

npm i https://pkg.pr.new/@authup/core-realtime-kit@3199

@authup/errors

npm i https://pkg.pr.new/@authup/errors@3199

@authup/i18n

npm i https://pkg.pr.new/@authup/i18n@3199

@authup/kit

npm i https://pkg.pr.new/@authup/kit@3199

@authup/server-adapter-kit

npm i https://pkg.pr.new/@authup/server-adapter-kit@3199

@authup/server-adapter-node

npm i https://pkg.pr.new/@authup/server-adapter-node@3199

@authup/server-adapter-socket-io

npm i https://pkg.pr.new/@authup/server-adapter-socket-io@3199

@authup/server-adapter-web

npm i https://pkg.pr.new/@authup/server-adapter-web@3199

@authup/server-kit

npm i https://pkg.pr.new/@authup/server-kit@3199

@authup/server-test-kit

npm i https://pkg.pr.new/@authup/server-test-kit@3199

@authup/specs

npm i https://pkg.pr.new/@authup/specs@3199

commit: a8db325

@tada5hi tada5hi changed the title feat: drop implicit & hybrid oauth2 response types (plan 042) feat: drop implicit & hybrid oauth2 response types Jul 8, 2026
@tada5hi

tada5hi commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tada5hi

tada5hi commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 24 minutes.

@tada5hi

tada5hi commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/server-core/test/unit/core/oauth2/authorization/code-request/verifier/module.spec.ts (1)

138-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider asserting the specific error code for the PKCE rejection.

The test uses rejects.toThrow() without checking the error, so it could pass even if the verifier rejects for a different reason (e.g., response_type validation rather than missing PKCE). Asserting the expected error code would ensure the test validates the intended behavior — that PKCE is required for public clients.

♻️ Suggested refinement
         it('should require PKCE for public clients regardless of response_type (code-only pipeline)', async () => {
             const client = clientRepository.seed({ is_confidential: false });
             await expect(verifier.verify({
                 client_id: client.id,
                 response_type: OAuth2AuthorizationResponseType.TOKEN,
-            })).rejects.toThrow();
+            })).rejects.toThrow(expect.objectContaining({
+                code: ErrorCode.OAUTH_RESPONSE_TYPE_UNSUPPORTED,
+            }));
         });

Adjust the expected ErrorCode to match the actual PKCE-missing error thrown by the verifier.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/server-core/test/unit/core/oauth2/authorization/code-request/verifier/module.spec.ts`
around lines 138 - 143, The PKCE verifier test only checks that an error is
thrown, so it can pass for the wrong failure path. Update the spec in
module.spec.ts within the verifier test to assert the specific ErrorCode from
verifier.verify for the missing-PKCE rejection, using the existing
verifier/client fixture setup and the same public-client case, so the test
verifies PKCE enforcement rather than generic rejection.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@apps/server-core/test/unit/core/oauth2/authorization/code-request/verifier/module.spec.ts`:
- Around line 138-143: The PKCE verifier test only checks that an error is
thrown, so it can pass for the wrong failure path. Update the spec in
module.spec.ts within the verifier test to assert the specific ErrorCode from
verifier.verify for the missing-PKCE rejection, using the existing
verifier/client fixture setup and the same public-client case, so the test
verifies PKCE enforcement rather than generic rejection.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6568d6a4-5609-4de8-83cc-0efce4ef4574

📥 Commits

Reviewing files that changed from the base of the PR and between 781c097 and a8db325.

📒 Files selected for processing (14)
  • .agents/architecture.md
  • apps/client-web/pages/clients/[id]/url.vue
  • apps/server-core/src/adapters/http/controllers/entities/realm/module.ts
  • apps/server-core/src/adapters/http/controllers/workflows/authorize/module.ts
  • apps/server-core/src/adapters/http/controllers/workflows/authorize/types.ts
  • apps/server-core/src/app/modules/http/modules/controller.ts
  • apps/server-core/src/core/oauth2/authorization/code-request/validator.ts
  • apps/server-core/src/core/oauth2/authorization/code-request/verifier/module.ts
  • apps/server-core/src/core/oauth2/authorization/module.ts
  • apps/server-core/src/core/oauth2/authorization/types.ts
  • apps/server-core/test/unit/core/oauth2/authorization/code-request/verifier/module.spec.ts
  • apps/server-core/test/unit/core/oauth2/authorization/module.spec.ts
  • apps/server-core/test/unit/http/controllers/workflows/authorize.spec.ts
  • docs/src/guide/development/api-oauth2.md
💤 Files with no reviewable changes (3)
  • apps/server-core/src/adapters/http/controllers/workflows/authorize/module.ts
  • apps/server-core/src/adapters/http/controllers/workflows/authorize/types.ts
  • apps/server-core/src/app/modules/http/modules/controller.ts

@tada5hi
tada5hi merged commit 0c3108a into master Jul 8, 2026
21 of 23 checks passed
@tada5hi
tada5hi deleted the feat/oauth2-drop-implicit branch July 8, 2026 21:05
@github-actions github-actions Bot mentioned this pull request Jul 8, 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.

2 participants