Skip to content

feat: RFC 9207 issuer identification for op.Server and rp - #1046

Open
datlechin wants to merge 2 commits into
zitadel:mainfrom
datlechin:feat/rfc9207-iss
Open

datlechin wants to merge 2 commits into
zitadel:mainfrom
datlechin:feat/rfc9207-iss

Conversation

@datlechin

Copy link
Copy Markdown

Which Problems Are Solved

  • op.Server cannot send iss in authorization responses or advertise authorization_response_iss_parameter_supported (RFC 9207 sections 2 and 3), so its clients cannot detect mix-up attacks.
  • rp.CodeExchangeHandler ignores iss. It accepts a response with another server's iss, and one without iss from an OP that advertises support (section 2.4).

How the Problems Are Solved

OP, as proposed in #1043:

  • oidc.DiscoveryConfiguration.AuthorizationResponseIssParameterSupported (authorization_response_iss_parameter_supported,omitempty).
  • op.CodeResponseType.Issuer and oidc.Error.Issuer, both encoded as iss. oidc.Error.Issuer is json:"-", so token endpoint errors do not change.
  • form_post.html.tmpl renders iss. Without iss the page is byte-identical.
  • New ServerOption op.WithAuthorizationResponseIss(), off by default. With it, every error that /authorize redirects after the redirect_uri is validated carries iss from IssuerFromContext, in query, fragment and form_post mode. With no issuer in the context, server_error is rendered instead of redirected.
  • Docs on the option and on Server.Authorize: the implementation also sets the metadata field and Issuer on the responses it builds itself.

RP:

  • NewRelyingPartyOIDC reads authorization_response_iss_parameter_supported from discovery.
  • New rp.VerifyAuthorizationResponseIss(rp, form). Every iss must equal rp.Issuer() by simple string comparison. A missing iss fails only when discovery advertised support. Errors wrap rp.ErrAuthorizationResponseIss.
  • CodeExchangeHandler calls it before it reads error or code, so an error response with a wrong iss goes to the unauthorized handler, not the error handler.
  • The discovered flag is read through the optional rp.HasAuthorizationResponseIss interface, like HasUnauthorizedHandler, so custom RelyingParty implementations keep compiling.

Additional Changes

  • README features table lists RFC 9207.
  • Tests: Test_webServer_authorizeHandler_iss (query, fragment, form_post, error from Authorize, option off, no issuer, redirect-disabled error), TestAuthResponseURL and TestAuthResponseFormPost with CodeResponseType.Issuer, TestError_MarshalJSON, TestDiscoveryConfiguration_AuthorizationResponseIssParameterSupported, Test_CodeExchangeHandler_Iss (query and form_post) and TestVerifyAuthorizationResponseIss.

Additional Context

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.

op.Server: RFC 9207 issuer identification in authorization responses

1 participant