Negotiate CIMD token endpoint auth method - #6400
Conversation
CIMD documents from live clients can declare a preferred token_endpoint_auth_method this server does not support while also publishing a plural token_endpoint_auth_methods_supported list (OpenID Connect RP Metadata Choices 1.0) that includes a method the server does support, and the server rejected the whole document without ever looking at that list. Add TokenEndpointAuthMethodsSupported to ClientMetadataDocument and negotiate the effective auth method from it before falling back to the prior outright rejection, mirroring the same describes-capability-across-every-AS reading the grant_types/response_types filtering already applies to CIMD documents. The negotiated set stays the server's own supported constant rather than the AS discovery document's advertised methods, since discovery may legitimately advertise symmetric methods that CIMD documents are never allowed to declare. The change is a pure widening: no document accepted today becomes rejected, and the existing singular-only rejection test is unchanged. Signed-off-by: Aleksandr Filippov <71711753+alex-feel@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6400 +/- ##
==========================================
- Coverage 77.75% 77.69% -0.06%
==========================================
Files 750 750
Lines 72601 72609 +8
==========================================
- Hits 56448 56413 -35
- Misses 16148 16191 +43
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jhrozek
left a comment
There was a problem hiding this comment.
Reviewed the negotiation logic (security, code quality, architecture) — looks good. It only ever falls back to "none", never widens into a method the server doesn't already support, so there's no way to sneak past the forbidden symmetric-auth-method check. One minor note: TestBuildFositeClient_TokenEndpointAuthMethodDefault (cimd_decorator_test.go:434) tests a fallback that buildFositeClient no longer applies internally — worth deleting or repurposing to cover the declared-already-"none"-plus-plural-list branch, but not blocking.
Thank you for the contribution and I'm sorry for the long delay in reviews, this shouldn't happen. The last weeks were especially busy. I'll make a pass on your other PRs! |
Summary
CIMD documents from live clients (observed with ChatGPT) can declare a preferred
token_endpoint_auth_methodthis server does not support while also publishing a pluraltoken_endpoint_auth_methods_supportedlist (per OpenID Connect Relying Party Metadata Choices 1.0) that includes a method the server does support (none). The server rejected the whole document without ever consulting that list.TokenEndpointAuthMethodsSupportedtoClientMetadataDocument.grant_types/response_typesfiltering for CIMD documents.Fixes #6278
Type of change
Test plan
Ran
gofmt -lon the changed files,go build, andgo vetacrosspkg/authserver/...andpkg/oauthproto/...(all clean), andgo test -count=1 ./pkg/authserver/... ./pkg/oauthproto/...(all packages green).TestFetch_TokenEndpointAuthMethodNegotiationcovering three cases: an unsupported singular method rescued bynonein the supported list, an unsupported singular method with no mutually supported method still rejected, and an omitted singular method with a plural list present accepted exactly as before.TestFetch_RejectsUnsupportedTokenEndpointAuthMethodis unchanged and still green, so the previously pinned contract for singular-only documents holds.Changes
pkg/oauthproto/cimd/fetch.goTokenEndpointAuthMethodsSupported []stringfield toClientMetadataDocumentpkg/authserver/storage/cimd_decorator.gonegotiateTokenEndpointAuthMethod; pass the negotiated method intobuildFositeClientas a new parameter, removing its internal empty-to-nonefallbackpkg/authserver/storage/cimd_decorator_test.goDoes this introduce a user-facing change?
Yes: CIMD clients previously rejected outright for declaring an unsupported preferred
token_endpoint_auth_methodare now accepted when theirtoken_endpoint_auth_methods_supportedlist names a method this server supports (none). This is a pure widening: no document accepted today becomes rejected.Special notes for reviewers
nonerather than the value the discovery endpoint advertises, because discovery may legitimately advertiseclient_secret_basic/client_secret_postfor other client types, and CIMD documents are never allowed to declare symmetric methods.TestFetch_RejectsUnsupportedTokenEndpointAuthMethodtest is unchanged and still passes, so the previously pinned contract for singular-only documents holds.