Skip to content
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

Honor custom_access_token_attributes in client credentials grant flow #1673

Merged

Conversation

mlr
Copy link
Contributor

@mlr mlr commented Oct 6, 2023

Summary

This change supports the custom_access_token_attributes configuration for Client Credentials grant_flow type.

Without this change, the custom configured attributes are not passed along during the token creation for client credentials requests, which leads to an error similar to:

Mysql2::Error - Field 'tenant_id' doesn't have a default value

If a default of null is provided for the field instead, the result will be the column is not populated with the tenant_id provided during the client credentials request.

Other Information

Steps to reproduce:

  1. Install doorkeeper following standard instructions for Rails application
  2. Configure the initializer with:
    grant_flows %w[client_credentials] and
    custom_access_token_attributes [:tenant_id]
  3. Modify the oauth_access_tokens and oauth_access_grants tables with the tenant_id field as described by the initializer comment for custom_access_token_attributes.
  4. Create a Doorkeeper::Application and obtain the client id and client secret.
  5. Make a credentials request to obtain a token, i.e.
    curl -H 'Content-Type: application/json' -XPOST 'http://localhost:3000/oauth/token' \
       -d '{ "client_id": "[client id]", "client_secret": "[client secret]", "grant_type": "client_credentials", "tenant_id": "1" }'
    
  6. Observe the database exception above which happens because the tenant_id field is not passed along during token creation.

Copy link
Member

@nbulaj nbulaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Thanks!

@nbulaj nbulaj merged commit 0aa94c5 into doorkeeper-gem:main Oct 10, 2023
21 checks passed
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.

None yet

2 participants