fix: conditionally omit userinfo_endpoint and access_token from verifier-OP#382
Conversation
…ier-OP The verifier-OP is not a traditional IdP and does not maintain persistent user sessions. Previously it unconditionally advertised userinfo_endpoint in its discovery metadata and returned access/refresh tokens in the token response. This confused standard OIDC RP libraries (e.g. coreos/go-oidc) that expect these to work together per OIDC Core. Changes: - Add EnableUserInfo config field to OIDCOP (default: false) - When false: omit userinfo_endpoint from discovery metadata - When false: omit access_token and refresh_token from token response - TokenResponse struct uses omitempty for access_token and expires_in - DiscoveryMetadata struct uses omitempty for userinfo_endpoint - Update tests to reflect default (no UserInfo) behavior Setting enable_userinfo: true restores the previous behavior for deployments where the OP supports real UserInfo sessions. Closes SUNET#381
There was a problem hiding this comment.
Pull request overview
This PR introduces a configuration switch to make the verifier’s OIDC OP behave more like a “verifier-mode OP” by avoiding advertising/issuing artifacts (UserInfo endpoint + access/refresh tokens) that aren’t usable without persistent user sessions, reducing incompatibilities with standard OIDC RP libraries.
Changes:
- Add
enable_userinfo(EnableUserInfo) toOIDCOPconfig (default false). - Conditionally omit
userinfo_endpointfrom discovery and omitaccess_token/refresh_token/expires_infrom token responses when disabled. - Update verifier OIDC tests to assert the new default behavior and cover discovery behavior when enabled.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pkg/model/config.go |
Adds EnableUserInfo flag to OIDC OP configuration. |
internal/verifier/apiv1/handler_oidc.go |
Gates UserInfo discovery + access/refresh token issuance behind EnableUserInfo; adds omitempty where needed. |
internal/verifier/apiv1/handler_oidc_test.go |
Updates tests for default no-UserInfo behavior and discovery behavior when enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…Info=true test - Conditionally include 'implicit' and 'refresh_token' in grant_types_supported only when EnableUserInfo is true, keeping discovery metadata consistent with actual token endpoint behavior. - Add TestToken_EnableUserInfoTrue covering the full access/refresh token flow and session persistence when EnableUserInfo is enabled. - Update discovery test to assert refresh_token/implicit are NOT advertised when EnableUserInfo is false.
When enable_userinfo is true, the token endpoint now issues a signed JWT access token (typ: at+jwt) containing the same claims as the id_token. The userinfo endpoint validates the JWT signature, expiration, and issuer inline — no session lookup or database required. Changes: - Replace opaque access token with signed JWT (generateAccessToken) - Make GetUserInfo fully stateless via JWT validation - Remove refresh token generation (unnecessary for stateless flow) - Remove refresh_token from advertised grant types - Update tests for JWT-based access tokens and stateless userinfo
Stateless UserInfo endpoint (commit 9f27985)Building on the How it works
FlowThe JWKS endpoint already publishes the public key, so RPs can also validate the access token independently. WhySome OIDC RP libraries (e.g. |
… grant, update docs - GetUserInfo now returns 404 when EnableUserInfo=false (not just hidden in discovery) - Validate JWT typ=at+jwt header per RFC 9068 to reject id_tokens at userinfo - Remove implicit grant type from discovery (not implemented regardless of mode) - Document enable_userinfo field in CONFIGURATION.md
The EnableUserInfo guard added in the previous commit requires the test to explicitly enable the feature for the userinfo endpoint tests.
|



Closes #381
Problem
The verifier-OP unconditionally advertises
userinfo_endpointin its discovery metadata and returnsaccess_token/refresh_tokenin the token response. Since the verifier has no persistent user sessions, the access token is unusable at the UserInfo endpoint. This confuses standard OIDC RP libraries (coreos/go-oidc,golang.org/x/oauth2) that discover the endpoint and expect the access token to work there per OIDC Core §5.3.Fix
Add
enable_userinfoconfig field toOIDCOP(default:false).When
false(verifier mode):userinfo_endpointis omitted from/.well-known/openid-configurationaccess_token,refresh_token, andexpires_inare omitted — onlyid_token,token_type, andscopeare returnedWhen
true(traditional OP mode):Changes
pkg/model/config.goEnableUserInfo booltoOIDCOPstructinternal/verifier/apiv1/handler_oidc.goomitemptyonTokenResponse.AccessTokenandDiscoveryMetadata.UserInfoEndpointinternal/verifier/apiv1/handler_oidc_test.goEnableUserInfo: trueConfiguration