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

Allow a TokenResponse body to be customized #1697

Merged
merged 2 commits into from
Mar 13, 2024

Commits on Mar 12, 2024

  1. Allow a TokenResponse body to be customized

    We have a use case where we need to include some additional information
    in the token response body to help the client applications with our
    multi-tenant setup.
    
    Adding the memoization allows us to modify the body object during the
    after_successful_authorization callback:
    
    ```ruby
      after_successful_authorization do |controller, context|
        case context.auth
        when Doorkeeper::OAuth::TokenResponse
          context.auth.body["tenant_id"] = context.auth.token.tenant_id
        end
      end
    ```
    
    (Assuming that `tenant_id` was added to `custom_access_token_attributes`.)
    
    I considered adding attributes via `custom_access_token_attributes` in
    `#body` directly, but that would change the existing behavior of the
    `TokenResponse` everywhere.
    kmayer committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    1d51a1c View commit details
    Browse the repository at this point in the history
  2. add PR ID

    kmayer committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    01343d1 View commit details
    Browse the repository at this point in the history