register took token_endpoint_auth_methods_supported[0] whenever the list
had no "none", and moved it to client_secret_post only when that was
listed. A server listing ["private_key_jwt", "client_secret_basic"] passed
the "magpie can do one of these" check and then had magpie registered for
private_key_jwt, which it can't do: the registration is refused
(invalid_client_metadata) or, if taken, the code exchange is. RFC 8414's
list has no order of preference.
What changed:
- register picks client_secret_post where listed, else
client_secret_basic, else says the server takes only what magpie can't
do, as before. "none" is still taken first.
- mcpauthtest.Fake gets AuthMethods: its metadata lists them, a
registration it can't honour without jwks or a certificate is refused,
a client registered for a secret is given one, and the token endpoint
checks it as registered.
Run:
- TestSignInBySecretBasic fails with the old register ("registering
magpie with the server's sign-in failed (400): invalid_client_metadata
... private_key_jwt") and passes now.
- go test -tags nogui ./internal/mcpauth/... ./internal/library/...
./internal/gateway/... under a temp HOME; gofmt -l; GOOS=linux and
GOOS=windows go vet -tags nogui.
- Not tried against a real authorization server that lists methods this
way; the reporter found none in the wild either.
Patch by ggbdpq in #1490, taken as is.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>