-
Notifications
You must be signed in to change notification settings - Fork 593
feat(oauth-server): store and enforce token_endpoint_auth_method #2300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(oauth-server): store and enforce token_endpoint_auth_method #2300
Conversation
cemalkilic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @dulacp, thank you for the contribution!
I'll double check if the migration is idempotent
fa3a91b to
9235e2a
Compare
|
Hi again @dulacp, sorry for the delay. We’re back to this now. CI is failing on a couple of tests; could you take a look and push a fix when you get a chance? Happy to jump in if you don't. |
08583ec to
0e65eea
Compare
|
Thank @cemalkilic for your message. I found the fix and was able to make the tests pass locally! |
Pull Request Test Coverage Report for Build 20724067486Details
💛 - Coveralls |
|
Thanks @dulacp ! Tested and confirmed everything is working fine! One last request (I can't push changes to your fork), can you add the annotation -- Add token_endpoint_auth_method column to oauth_clients table
-- Per RFC 7591: "If unspecified or omitted, the default is 'client_secret_basic'"
-- For public clients, the default is 'none' since they don't have a client secret
/* auth_migration: 20251216000000 */
alter table {{ index .Options "Namespace" }}.oauth_clients
add column if not exists token_endpoint_auth_method text check (token_endpoint_auth_method in ('client_secret_basic', 'client_secret_post', 'none'));
-- Set default values for existing clients based on their client_type
/* auth_migration: 20251216000000 */
update {{ index .Options "Namespace" }}.oauth_clients
set token_endpoint_auth_method = case
when client_type = 'public' then 'none'
else 'client_secret_basic'
end
where token_endpoint_auth_method is null;
-- Now make the column not null
/* auth_migration: 20251216000000 */
alter table {{ index .Options "Namespace" }}.oauth_clients
alter column token_endpoint_auth_method set not null; |
|
@cemalkilic annotations added 👍, thanks for guiding me through this I wasn't sure how and where to add these. |
- Add database migration for token_endpoint_auth_method column (nullable text) - Store and enforce token_endpoint_auth_method during client registration - Refactor ExtractClientCredentials to identify which auth method was used - Add ValidateClientAuthMethod to compare used vs registered method - Update middleware to enforce auth method matching - Legacy clients (NULL) remain permissive for backward compatibility - New clients get strict enforcement per OAuth 2.0 spec Signed-off-by: Pierre Dulac <[email protected]> Signed-off-by: Pierre Dulac <[email protected]>
Adjust the indendation and use `slices.Contains` to stay consistent with the codebase. Signed-off-by: Pierre Dulac <[email protected]> Signed-off-by: Pierre Dulac <[email protected]>
d20d85a to
2f54d9f
Compare
|
I've made a rebase on master to fix a small conflict. |
Problem
I noticed there was a TODO for storing the
token_endpoint_auth_methodvalue. While integrating with Claude.ai's OAuth flow, we discovered that returningclient_secret_basicfor all clients (regardless of their actual registration) was breaking the authentication flow. Claude.ai strictly validates the auth method returned during client registration, so it was critical for us to return the correct value.Per RFC 7591 Section 2:
For public clients, the default is
nonesince they don't have a client secret.Solution
Added proper storage and enforcement of
token_endpoint_auth_method:Database Changes
token_endpoint_auth_methodTEXT column (NOT NULL) tooauth_clientstableclient_type:confidential→client_secret_basicpublic→noneBehavior
token_endpoint_auth_methodpersisted during registrationtoken_endpoint_auth_methodin client registration responses