Skip to content

feat(op): RFC 9207 issuer identification in authorization responses - #1006

Open
azuretek wants to merge 4 commits into
zitadel:mainfrom
azuretek:feat-op-rfc9207-iss
Open

azuretek wants to merge 4 commits into
zitadel:mainfrom
azuretek:feat-op-rfc9207-iss

Conversation

@azuretek

@azuretek azuretek commented Oct 9, 2026 •

Copy link
Copy Markdown

Which Problems Are Solved

  • pkg/op does not implement RFC 9207. Authorization responses carry no iss parameter and discovery does not advertise authorization_response_iss_parameter_supported, so clients cannot detect mix-up attacks. MCP clients such as ChatGPT depend on it.

How the Problems Are Solved

  • Config.AuthorizationResponseIssParameterSupported turns RFC 9207 on. It is off by default, and one setting drives both emission and discovery. Section 2.4 has clients reject responses without iss once support is advertised, and discard responses with iss when it is not, so turning on only one of the two would break clients.
  • AuthorizationResponseIssConfiguration is an optional interface implemented by Provider and LegacyServer. Existing Configuration implementations and the generated mock keep compiling. The op.Server authorize handler decides from the provider of an ExtendedLegacyServer, as discovery and the callback do, so a server that embeds the interface still emits iss.
  • When it is enabled, the issuer from IssuerFromContext is set as iss on every authorization response:
    • code and token responses, in query, fragment and form_post mode;
    • error redirects from AuthRequestError, LegacyServer.Authorize and the op.Server authorize handler.
    • In query mode, an iss already in the query of the registered redirect URI is removed, so the response carries exactly one issuer. In fragment and form_post mode the registered query is kept as is, since the OP's iss goes in the fragment or the POST body.
    • Errors are only redirected to an already validated redirect_uri, so iss never reaches an untrusted target.
  • AuthResponseURL, AuthResponseFormPost and TryErrorRedirect keep their signatures, never set iss, and are deprecated. AuthResponseURLWithIssuer, AuthResponseFormPostWithIssuer and TryErrorRedirectWithIssuer are added alongside them, and AuthorizationResponseIss(ctx, v) returns the value to pass, logging an error when the setting is on and the context carries no issuer. Implementations that build their own callbacks can use these.
  • DiscoveryConfiguration gains AuthorizationResponseIssParameterSupported, set by both CreateDiscoveryConfig and the op.Server discovery.

Additional Changes

  • form_post.html.tmpl renders iss. The template only renders the parameters it names, so without this form_post responses would drop it. With the setting off, the rendered page is byte-identical to before.
  • The README features table lists RFC 9207 for the OpenID Provider.

Additional Context

  • Closes Support RFC 9207 issuer identification (iss) in authorization responses #1005
  • Validation: TestAuthorizationResponseIss runs discovery, a storage error, a validation error, code and id_token token responses in query, fragment and form_post mode against Provider, op.Server, and an op.Server that embeds ExtendedLegacyServer, with the setting on and off. TestAuthResponseURLWithIssuer and TestAuthResponseFormPostWithIssuer cover a redirect URI that already has iss. TestDiscover pins the JSON key. go test -race ./pkg/..., go vet ./pkg/... and Staticcheck 2026.2.1 with every CI build tag pass.
  • Validating iss on the RP side (pkg/client/rp) is left for a follow-up.

@wim07101993
wim07101993 requested a balanced review from Copilot October 10, 2026 07:49
@wim07101993 wim07101993 self-assigned this Oct 10, 2026
@wim07101993 wim07101993 added the os-contribution This is a contribution from our open-source community label Oct 10, 2026

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

Existing iss query parameters can produce ambiguous duplicate issuer values, and key response paths lack coverage.

3 open findings
What changed in this PR

Adds opt-in RFC 9207 issuer identification to authorization responses and discovery metadata.

Changes:

  • Adds configuration and discovery support for RFC 9207.
  • Emits iss in redirects, errors, fragments, and form-post responses.
  • Adds integration and helper tests plus README documentation.
File Description
README.md Documents RFC 9207 support.
pkg/​op/​server_legacy.go Enables issuer support in the legacy adapter.
pkg/​op/​server_http.go Adds issuer to server authorization errors.
pkg/​op/​op.go Adds the opt-in provider configuration.
pkg/​op/​form_post.html.tmpl Renders the iss form field.
pkg/​op/​error.go Adds issuer-aware error redirect helpers.
pkg/​op/​discovery.go Advertises issuer-parameter support.
pkg/​op/​authorization_response_iss_test.go Tests discovery and authorization responses.
pkg/​op/​auth_request.go Adds issuer-aware response helpers and emission.
pkg/​oidc/​discovery.go Defines the discovery metadata field.

🧠 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 pkg/op/auth_request.go Resolved
Comment thread pkg/op/auth_request.go Resolved
Comment thread pkg/op/discovery.go Resolved

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

Removing an existing iss currently rewrites unrelated callback query parameters.

3 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment thread pkg/op/auth_request.go Resolved

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.

🟢 Approval recommended

The implementation consistently couples discovery advertisement with issuer emission and includes comprehensive regression coverage.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

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.

🟢 Approval recommended

The implementation consistently couples discovery advertisement with issuer emission and includes comprehensive regression coverage.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

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

Thank you for the contribution. PR looks good but I have a few comments

Comment thread pkg/op/server_http.go Resolved
Comment thread pkg/op/auth_request.go Resolved
Comment thread pkg/op/auth_request.go Resolved
Comment thread pkg/op/auth_request.go Resolved
Comment thread pkg/op/server_legacy.go Resolved
Comment thread pkg/op/auth_request.go Resolved
Comment thread pkg/op/auth_request.go Resolved
@wim07101993 wim07101993 added the waiting-for-author AI triage asked the author questions; their reply re-runs triage label Nov 30, 2026
Add Config.AuthorizationResponseIssParameterSupported. When enabled, the
issuer is returned as the iss parameter on every authorization response
(code, token and error redirects, query, fragment and form_post) and
discovery advertises authorization_response_iss_parameter_supported.
One setting drives both, because RFC 9207 section 2.4 has clients reject
responses without iss once support is advertised.

The public helpers keep their signatures; AuthResponseURLWithIssuer,
AuthResponseFormPostWithIssuer and TryErrorRedirectWithIssuer are added
alongside them, and AuthorizationResponseIssuer is an optional interface
so existing Configuration implementations keep compiling.

Refs zitadel#1005
…ery response path

An iss already in the query of a registered redirect URI is removed when
the issuer is set, so the response carries exactly one. This applies to
query, fragment and form_post responses.

TestAuthorizationResponseIss now also covers token responses in fragment
and form_post mode, and discovery through both the Provider and op.Server
handlers.
Rebuilding the query through url.Values.Encode sorted and re-encoded every
other registered callback parameter, which changed the query of fragment
and form_post responses. Only iss components are now dropped, and all
other components keep their original order and encoding.
…side query mode

- The op.Server authorize error redirect decides from the provider of an
  ExtendedLegacyServer, as discovery and the callback do, so a server that
  embeds the interface no longer hides the setting.
- iss is removed from the redirect URI's query only in query mode. Fragment
  and form_post responses keep the registered query as is.
- AuthorizationResponseIss logs an error when the setting is on and the
  context carries no issuer.
- AuthResponseURL, AuthResponseFormPost and TryErrorRedirect are deprecated
  in favour of their WithIssuer variants, and say they never set iss.
- AuthorizationResponseIssuer is renamed AuthorizationResponseIssConfiguration,
  and its docs say an embedded interface hides it.
- Tests: an op.Server embedding ExtendedLegacyServer, absent rather than
  empty iss, the escaped fragment, the code in the disabled form_post case,
  and the discovery key on the wire.

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.

🟢 Approval recommended

No active review issues are recorded for the opt-in RFC 9207 issuer-identification change.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

os-contribution This is a contribution from our open-source community waiting-for-author AI triage asked the author questions; their reply re-runs triage

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

Support RFC 9207 issuer identification (iss) in authorization responses

3 participants