fix: Prefer the token_endpoint_auth_method response from DCR registration (#1022)

This commit is contained in:
Chip 2025-10-28 06:24:46 -05:00 • committed by GitHub
commit 874aa27a89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,7 +10,8 @@ import {
discoverOAuthProtectedResourceMetadata,
extractResourceMetadataUrl,
auth,
type OAuthClientProvider
type OAuthClientProvider,
selectClientAuthMethod
} from './auth.js';
import { ServerError } from '../server/auth/errors.js';
import { AuthorizationServerMetadata } from '../shared/auth.js';
@ -881,6 +882,25 @@ describe('OAuth Authorization', () => {
});
});
describe('selectClientAuthMethod', () => {
it('selects the correct client authentication method from client information', () => {
const clientInfo = {
client_id: 'test-client-id',
client_secret: 'test-client-secret',
token_endpoint_auth_method: 'client_secret_basic'
};
const supportedMethods = ['client_secret_post', 'client_secret_basic', 'none'];
const authMethod = selectClientAuthMethod(clientInfo, supportedMethods);
expect(authMethod).toBe('client_secret_basic');
});
it('selects the correct client authentication method from supported methods', () => {
const clientInfo = { client_id: 'test-client-id' };
const supportedMethods = ['client_secret_post', 'client_secret_basic', 'none'];
const authMethod = selectClientAuthMethod(clientInfo, supportedMethods);
expect(authMethod).toBe('none');
});
});
describe('startAuthorization', () => {
const validMetadata = {
issuer: 'https://auth.example.com',