You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add consent-info endpoint and redirect HandleAuthorize to UI consent page (#2157)
* feat: Add consent-info endpoint and redirect HandleAuthorize to UI consent page
Task 3: Add HandleConsentInfo endpoint that returns client metadata (name,
redirect_uri, scopes, is_dynamic) for the UI consent page. Modify
HandleCallback to consume consent codes from ConsentCodeStore instead of
exchanging Dex authorization codes. Add scopes claim to issued JWTs.
Task 4: When ConsentStore is configured, HandleAuthorize redirects to
/auth/mcp-consent on the tenant-scoped domain instead of Dex. Default
scopes to ["mcp:default"] when no scope parameter is provided.
Introduces ConsentCodeConsumer interface to avoid importing api-gateway
(which pulls in broken otel transitive deps). Both Dex and consent
paths are preserved - consent path activates when ConsentStore is set.
* refactor: Extract consent and callback logic into oidc_consent.go
Move ConsentEntry, ConsentCodeConsumer, ConsentInfoResponse types,
HandleConsentInfo, handleConsentCallback, handleDexCallback,
buildConsentRedirect, and buildConsentPageURL into oidc_consent.go
to keep oidc.go under the 800-line service convention limit.
* fix: Add scope escalation guard in consent callback
Add scope subset validation in handleConsentCallback to reject consent
codes whose ApprovedScopes exceed the originally RequestedScopes,
preventing over-privileged token issuance.
Note: /oauth/consent-info mux registration deferred to the wiring task
(main.go pre-commit lint fails due to pre-existing otel dep breakage).
* fix: guard consent URL construction and fix stale comment
- Return error from buildConsentPageURL when both baseURL and baseDomain
are empty, preventing malformed "https:///" redirects
- Fix stale comment on resolveTenantSlug that referenced handleDexCallback
* fix: validate BaseURL scheme/host and filter scopes to mcp: prefix
Address CodeRabbit security feedback:
- buildConsentPageURL now validates that BaseURL has both scheme and host,
rejecting malformed relative URLs
- filterAllowedScopes restricts requested scopes to mcp: prefix only,
preventing clients from injecting arbitrary scope strings into signed JWTs
* fix: validate consent base URL before storing flow state
Prevent orphaned state store entries when BaseURL/BaseDomain is
misconfigured by validating the consent configuration before writing
to the state store.
---------
Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>
0 commit comments