Skip to content

fix: use slug in callback-uri - #1633

Merged
livio-a merged 14 commits into
mainfrom
fix/use-slug-in-callback-uri
Oct 14, 2026
Merged

livio-a merged 14 commits into
mainfrom
fix/use-slug-in-callback-uri

Conversation

@wim07101993

@wim07101993 wim07101993 commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Context

Summary

Each sign-in provider connection now has its own callback route, GET /__nextgen/idp/{slug}/callback, also served as /idp/{slug}/callback for a scaffolded app's SDK proxy. The authorize request and the token exchange send it as redirect_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 example http://localhost:3000/__nextgen/idp/google/callback, or the provider answers redirect_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 records auth.sso.exchange.failed, or auth.sso.authorization.failed when no code arrived. When the provider sends the RFC 9207 iss parameter, the callback also refuses a value that is not the connection's issuer, the same way, provider error responses included. A response without iss is 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 the iss check 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 stays error.sso_cancelled. The SDK proxyPath docs and the Nuxt agent skill name the new route.

zitadel setup and zitadel sso enable show each connection's own redirect URI, {issuer}/__nextgen/idp/{slug}/callback. sso enable now prints it for an existing connection too, so rerunning zitadel sso enable --provider google shows the URI to register. setup --json reports it as callback_uri on each sso entry, as sso enable --json already did.

Validation

  • go test ./...
  • go test -tags sqlite_integration ./...
  • go test -tags postgres_integration ./...

Release notes / changeset

  • Changeset: .changeset/idp-callback-per-connection.md — use slug in callback-uri (list @zitadel/server for server changes)

Notes

@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Oct 14, 2026 12:03pm UTC
nextgen Error Error Oct 14, 2026 12:03pm UTC
nextgen-docs Ready Ready Preview Oct 14, 2026 12:03pm UTC
nextgen-mock-zitadel Ready Ready Preview Oct 14, 2026 12:03pm UTC
nextgen-storybook Ready Ready Preview Oct 14, 2026 12:03pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: 5bba53c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 20 packages
Name Type
@zitadel/cli Minor
@zitadel/server Minor
@zitadel/sdk-core Minor
@zitadel/sdk-next Minor
@zitadel/sdk-nuxt Minor
@zitadel/testing Minor
@zitadel/sdk-angular Minor
@zitadel/sdk-qwik Minor
@zitadel/sdk-react Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-vue Minor
@zitadel/server-linux-x64 Minor
@zitadel/server-linux-arm64 Minor
@zitadel/server-darwin-x64 Minor
@zitadel/server-darwin-arm64 Minor
@zitadel/server-win32-x64 Minor
@zitadel/api Minor
@zitadel/config Minor
@zitadel/components Minor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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.

Comment thread internal/service/flow_sso_callback.go Resolved
Comment thread apps/cli/src/commands/setup/index.ts Resolved
Comment thread docs/design/api/events-catalog.md Resolved
@wim07101993
wim07101993 requested a balanced review from Copilot October 9, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Retired callback paths expose authorization codes and state values through unredacted request logs.

2 open findings
3 resolved since last review

🧠 Review effort: Balanced

Comment thread cmd/server/server.go Resolved
Comment thread apps/cli/src/commands/setup/index.ts Resolved
@wim07101993

Copy link
Copy Markdown
Member Author

@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>

Copilot AI commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@copilot solve the merge conflicts

Merged current main and resolved the five conflicts in ca52fe7. Focused setup/SSO tests and CLI typecheck pass.

Co-authored-by: wim07101993 <23017340+wim07101993@users.noreply.github.com>

@livio-a livio-a left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread cmd/server/server.go Resolved
Comment thread internal/service/flow_sso_callback.go Resolved
Comment thread internal/service/flow_sso_callback.go Resolved
Comment thread internal/service/flow_sso_callback.go Resolved
Comment thread internal/api/flow_sso.go Resolved

@livio-a livio-a left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, all addressed. The iss-required follow-up can wait for zitadel/oidc#1006.

@livio-a
livio-a added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit 290dfe6 Oct 14, 2026
15 of 16 checks passed
@livio-a
livio-a deleted the fix/use-slug-in-callback-uri branch October 14, 2026 13:30
@github-project-automation github-project-automation Bot moved this from Ready to Done in Engineering Kanban Oct 14, 2026

This branch had an error being deployed

1 failed (outdated), 3 active (2 outdated), and 1 inactive (outdated) deployments
Preview — 5bba53c6 Deployed Oct 14, 2026 by vercel[bot]
Preview – nextgen-mock-zitadel — ae91fe4f Deployed Oct 12, 2026 by vercel[bot]
Preview – nextgen-docs — ae91fe4f Deployed Oct 12, 2026 by vercel[bot]
Preview – nextgen-storybook — ae91fe4f Deployed Oct 12, 2026 by vercel[bot]
Preview – nextgen — ae91fe4f Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Flow engine - per-connection IdP callback URI (mix-up defense)

4 participants