Repository navigation
fix: use slug in callback-uri - #1633
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 5bba53c The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
🟡 Changes recommended
Foreign issuer values on provider error responses bypass validation, and the CLI contract documentation is not synchronized.
3 open findings
What changed in this PR
Introduces per-connection IdP callback routes to mitigate provider mix-up attacks and exposes the new URI through CLI and SDK surfaces.
Changes:
- Adds slug-specific callback routing with path and issuer validation.
- Updates setup and SSO CLI output with per-connection callback URIs.
- Expands tests, documentation, and release notes for the new contract.
| File | Description |
|---|---|
packages/sdk-nuxt/README.md |
Documents the slug callback path. |
packages/sdk-next/README.md |
Documents the slug callback path. |
packages/sdk-core/src/middleware.ts |
Updates proxy callback documentation. |
packages/sdk-core/src/middleware.spec.ts |
Updates redirect-resolution fixtures. |
internal/storage/stmttest/auth_attempt_sso_state_test.go |
Updates stored callback URI fixture. |
internal/service/flow_test.go |
Updates SSO return URI fixture. |
internal/service/flow_sso_redirect_issuer_test.go |
Updates authorization URI fixture. |
internal/service/flow_sso_callback.go |
Adds mix-up and issuer validation. |
internal/service/flow_sso_callback_test.go |
Tests callback mismatch handling. |
internal/service/auth_attempt_test.go |
Updates issued-state URI assertions. |
internal/idp/authorize_test.go |
Updates authorization redirect fixture. |
internal/domain/flow_state_machine_test.go |
Updates state-machine callback fixture. |
internal/domain/event.go |
Documents refusal event classification. |
internal/domain/auth_check_type_sso_test.go |
Updates SSO state fixtures. |
internal/api/middleware/logging_test.go |
Verifies redaction on the new route. |
internal/api/integration_test/sso_submit_flow_test.go |
Verifies slug-specific authorization URI. |
internal/api/integration_test/sso_resolution_flow_test.go |
Updates parked-state callback URI. |
internal/api/integration_test/sso_callback_flow_test.go |
Tests routing, mix-up defense, and retirement. |
internal/api/integration_test/helpers/server.go |
Mounts callback routes in the harness. |
internal/api/idp_callback.go |
Extracts slug and issuer from callbacks. |
internal/api/idp_callback_test.go |
Tests callback routing and retired paths. |
internal/api/flow.go |
Generates the per-provider redirect URI. |
internal/api/flow_test.go |
Verifies generated redirect URI. |
internal/api/flow_sso.go |
Defines and mounts callback patterns. |
docs/design/idp/4-cli-provider-setup.md |
Updates provider registration guidance. |
docs/design/idp/3-social-login-flow.md |
Documents the new security model. |
docs/design/flowengine/flow-engine.md |
Updates the authorization example. |
docs/design/flowengine/flow-engine-external-auth-factors.md |
Distinguishes the new IdP route. |
docs/design/cli/identity-surface.md |
Updates the IdP callback surface. |
docs/design/api/events-catalog.md |
Updates SSO failure descriptions. |
cmd/server/server.go |
Mounts callbacks through the shared helper. |
cmd/server/mux_test.go |
Tests production mux routing. |
apps/cli/tests/unit/commands/sso-enable.test.ts |
Tests per-connection CLI output. |
apps/cli/tests/unit/commands/setup/prompts.test.ts |
Tests setup prompt output. |
apps/cli/tests/unit/commands/setup.test.ts |
Tests setup JSON callback URI. |
apps/cli/src/lib/idp/callback.ts |
Generates slug-specific callback URIs. |
apps/cli/src/commands/sso/enable.ts |
Reports callback URIs on create and reuse. |
apps/cli/src/commands/setup/prompts/social-sign-in.ts |
Displays provider-specific redirect URIs. |
apps/cli/src/commands/setup/index.ts |
Adds callback URIs to summaries and JSON. |
.changeset/idp-callback-per-connection.md |
Records server and SDK release intent. |
.changeset/cli-per-connection-callback-uri.md |
Records CLI release intent. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot solve the merge conflicts |
…ack-uri # Conflicts: # apps/cli/src/commands/setup/index.ts # apps/cli/src/commands/sso/enable.ts # apps/cli/tests/unit/commands/sso-enable.test.ts # docs/design/idp/3-social-login-flow.md # packages/sdk-nuxt/README.md Co-authored-by: wim07101993 <23017340+wim07101993@users.noreply.github.com>
Merged current |
Co-authored-by: wim07101993 <23017340+wim07101993@users.noreply.github.com>
livio-a
left a comment
There was a problem hiding this comment.
Design looks good and the callback ordering (path check, then iss, then the error branch) is right. One blocker plus a few smaller things inline.
Blocking: apps/cli/tests/unit/commands/setup/prompts.test.ts:489: this assertion still expects the shared http://localhost:4321/__nextgen/idp/callback, but the prompt now prints the slugged URI, so it can't pass. I think it came in with the main merge, which is why only the google case got updated. Could you change it to the custom provider's slug, e.g. …/__nextgen/idp/<slug>/callback?
Nit: packages/sdk-nuxt/skills/zitadel-sdk-nuxt/SKILL.md:130: this still says the provider returns to /__nextgen/idp/callback. The README and sdk-core docs were updated, but this agent skill wasn't. Please make it /__nextgen/idp/{slug}/callback too.
livio-a
left a comment
There was a problem hiding this comment.
Thanks, all addressed. The iss-required follow-up can wait for zitadel/oidc#1006.


Context
Summary
Each sign-in provider connection now has its own callback route,
GET /__nextgen/idp/{slug}/callback, also served as/idp/{slug}/callbackfor a scaffolded app's SDK proxy. The authorize request and the token exchange send it asredirect_uri.zitadel sso enable --provider <slug>prints it.The shared
/__nextgen/idp/callback(and/idp/callback) route, which shipped in #1478, is removed. This is a breaking change: if you registered it at a provider, register the connection's own URI instead, for examplehttp://localhost:3000/__nextgen/idp/google/callback, or the provider answersredirect_uri_mismatch. A callback that still reaches the removed route is not served: it falls through to the API's catch-all and gets a 404, and its query is logged as received.The route defends against the IdP mix-up attack (RFC 9700 §4.4): a callback whose path names another connection than the one the sign-in started with is refused before any code exchange. The step the sign-in started from shows
error.sso_failed, and the events stream recordsauth.sso.exchange.failed, orauth.sso.authorization.failedwhen no code arrived. When the provider sends the RFC 9207issparameter, the callback also refuses a value that is not the connection's issuer, the same way, provider error responses included. A response withoutissis not refused, even from a provider that advertises support for it (RFC 9207 §2.4): the per-connection path already covers the mix-up, so that check is left for a follow-up. The callback loads the connection at most once, and only when theisscheck or the exchange needs it. When it cannot be loaded for a provider error response, the provider's error is still shown, so a declined sign-in stayserror.sso_cancelled. The SDKproxyPathdocs and the Nuxt agent skill name the new route.zitadel setupandzitadel sso enableshow each connection's own redirect URI,{issuer}/__nextgen/idp/{slug}/callback.sso enablenow prints it for an existing connection too, so rerunningzitadel sso enable --provider googleshows the URI to register.setup --jsonreports it ascallback_urion eachssoentry, assso enable --jsonalready did.Validation
go test ./...go test -tags sqlite_integration ./...go test -tags postgres_integration ./...Release notes / changeset
Notes