Skip to content

Negotiate CIMD token endpoint auth method - #6400

Merged
jhrozek merged 1 commit into
stacklok:mainfrom
alex-feel:cimd-auth-methods-fallback
Aug 27, 2026
Merged

Negotiate CIMD token endpoint auth method#6400
jhrozek merged 1 commit into
stacklok:mainfrom
alex-feel:cimd-auth-methods-fallback

Conversation

@alex-feel

Copy link
Copy Markdown
Contributor

Summary

CIMD documents from live clients (observed with ChatGPT) can declare a preferred token_endpoint_auth_method this server does not support while also publishing a plural token_endpoint_auth_methods_supported list (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.

  • Add TokenEndpointAuthMethodsSupported to ClientMetadataDocument.
  • Negotiate the effective auth method: accept the declared singular method when supported, otherwise fall back to a mutually supported method from the plural list, otherwise reject with the existing error, which now names both fields.
  • This follows the same describes-capability-across-every-AS reading already applied to grant_types/response_types filtering for CIMD documents.

Fixes #6278

Type of change

  • Bug fix

Test plan

  • Manual testing (describe below)

Ran gofmt -l on the changed files, go build, and go vet across pkg/authserver/... and pkg/oauthproto/... (all clean), and go test -count=1 ./pkg/authserver/... ./pkg/oauthproto/... (all packages green).

  • Added TestFetch_TokenEndpointAuthMethodNegotiation covering three cases: an unsupported singular method rescued by none in 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.
  • The pre-existing TestFetch_RejectsUnsupportedTokenEndpointAuthMethod is unchanged and still green, so the previously pinned contract for singular-only documents holds.

Changes

File Change
pkg/oauthproto/cimd/fetch.go Add the TokenEndpointAuthMethodsSupported []string field to ClientMetadataDocument
pkg/authserver/storage/cimd_decorator.go Replace the outright-rejection guard with negotiateTokenEndpointAuthMethod; pass the negotiated method into buildFositeClient as a new parameter, removing its internal empty-to-none fallback
pkg/authserver/storage/cimd_decorator_test.go New negotiation test table; existing rejection test untouched; build-helper calls updated for the new parameter

Does this introduce a user-facing change?

Yes: CIMD clients previously rejected outright for declaring an unsupported preferred token_endpoint_auth_method are now accepted when their token_endpoint_auth_methods_supported list names a method this server supports (none). This is a pure widening: no document accepted today becomes rejected.

Special notes for reviewers

  • Two deliberate boundaries: (1) this only widens acceptance, it introduces no new rejections; (2) the server's supported-method set stays the constant none rather than the value the discovery endpoint advertises, because discovery may legitimately advertise client_secret_basic/client_secret_post for other client types, and CIMD documents are never allowed to declare symmetric methods.
  • The existing TestFetch_RejectsUnsupportedTokenEndpointAuthMethod test is unchanged and still passes, so the previously pinned contract for singular-only documents holds.

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>
@alex-feel

Copy link
Copy Markdown
Contributor Author

Could a maintainer approve the first-contributor workflow runs on this PR and the sibling auth-server PRs (#6283, #6284, #6288)? None of the four has had CI run yet, and green checks should make review easier. I will address whatever the checks surface.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.69%. Comparing base (d278b33) to head (4f321f6).
⚠️ Report is 30 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

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.

@jhrozek

jhrozek commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Could a maintainer approve the first-contributor workflow runs on this PR and the sibling auth-server PRs (#6283, #6284, #6288)? None of the four has had CI run yet, and green checks should make review easier. I will address whatever the checks surface.

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!

@jhrozek
jhrozek merged commit 8fa9220 into stacklok:main Aug 27, 2026
44 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 27, 2026
2 tasks
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.

CIMD rejects clients that advertise a supported fallback auth method

2 participants