Commit 9e6feff
feat(oauth): select token_endpoint_auth_method from AS metadata (RFC 8414) (#62)
* feat(oauth): select token_endpoint_auth_method from AS metadata (RFC 8414)
Read `token_endpoint_auth_methods_supported` from RFC 8414 Authorization
Server Metadata and pick the best supported auth method for the token
endpoint (preference: none → client_secret_post → client_secret_basic).
Apply the selected method consistently across DCR, code exchange, token
refresh, and Device Authorization Grant polling.
RFC 6749 §2.3.1 `client_secret_basic` sends credentials as
`Authorization: Basic base64(percent_encode(id):percent_encode(secret))`
instead of in the request body. The selected method is stored in
`TokenData.token_endpoint_auth_method` so refresh reuses it without
re-reading the discovery document.
Fixes compatibility with Microsoft Entra ID v2 and other enterprise OIDC
providers that publish only `client_secret_basic` in
`token_endpoint_auth_methods_supported` and reject `none`/body-credential
requests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(oauth): add device authorization Step 1 Basic auth test
Verify that client_secret_basic sends credentials in the Authorization
header (not the request body) for the device authorization request
itself (Step 1, RFC 8628 §3.1), not just the token polling loop.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 1bb9ee5 commit 9e6feff
6 files changed
Lines changed: 507 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
0 commit comments