Repository navigation
feat: drop implicit & hybrid oauth2 response types - #3199
Conversation
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.
📝 WalkthroughWalkthroughThis PR restricts OAuth2/OIDC authorization to ChangesAuthorization-code-only flow
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
authup
@authup/client-web
@authup/server-core
@authup/access
@authup/client-web-kit
@authup/client-web-kit-theme
@authup/client-web-nuxt
@authup/client-web-theme
@authup/core-http-kit
@authup/core-kit
@authup/core-realtime-kit
@authup/errors
@authup/i18n
@authup/kit
@authup/server-adapter-kit
@authup/server-adapter-node
@authup/server-adapter-socket-io
@authup/server-adapter-web
@authup/server-kit
@authup/server-test-kit
@authup/specs
commit: |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 24 minutes. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
🧹 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 winConsider 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
ErrorCodeto 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
📒 Files selected for processing (14)
.agents/architecture.mdapps/client-web/pages/clients/[id]/url.vueapps/server-core/src/adapters/http/controllers/entities/realm/module.tsapps/server-core/src/adapters/http/controllers/workflows/authorize/module.tsapps/server-core/src/adapters/http/controllers/workflows/authorize/types.tsapps/server-core/src/app/modules/http/modules/controller.tsapps/server-core/src/core/oauth2/authorization/code-request/validator.tsapps/server-core/src/core/oauth2/authorization/code-request/verifier/module.tsapps/server-core/src/core/oauth2/authorization/module.tsapps/server-core/src/core/oauth2/authorization/types.tsapps/server-core/test/unit/core/oauth2/authorization/code-request/verifier/module.spec.tsapps/server-core/test/unit/core/oauth2/authorization/module.spec.tsapps/server-core/test/unit/http/controllers/workflows/authorize.spec.tsdocs/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
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=codeis the only supported response type. The code-request validator rejectstoken,id_token,none, and any hybrid combination;OAuth2Authorization.authorize()enforces the same as defense in depth (unsupported_response_type).confirm()loses itsaccess_token/id_tokensearchParamswrites — previously those tokens leaked via browser history, proxy/access logs, andReferer(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 (withc_hash); the/tokenexchange returns it — unchanged.response_types_supportednow advertises onlycode(previouslycode,token,none).statefor public clients are now unconditional — thewillIssueCodegate 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).OAuth2AuthorizationResultlosesaccessToken/idToken; the now-unusedaccessTokenIssuerwas removed from the authorize controller/authorization contexts and wiring.response_type=code.Error surface
At the HTTP layer a dropped response type yields the standard 400 validation shape (a
response_typeissue carrying theunsupported_response_typemessage) — consistent with how every other invalid/authorizeparameter 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 theprompt=nonework (plan 042 item 10).Tests
token,id_token,none,code token,id_token token) + code-issuance assertion inauthorization/module.spec.ts(spec reworked ontoresponse_type=codewith a working code-issuer stub)authorize.spec.tsrewritten — code flow still works, each dropped type 400s with aresponse_typeissue, and discovery advertises onlycodeFull server-core suite green (1163 tests; the known pre-existing
grant-authorizeFK 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
Bug Fixes