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

Doorkeeper.config.calculate_grant_flows does not list refresh_token if refresh tokens are enabled #1734

Open
ThisIsMissEm opened this issue Oct 2, 2024 · 3 comments

Comments

@ThisIsMissEm
Copy link
Contributor

Steps to reproduce

When using Doorkeeper with refresh tokens enabled, the returned grant flows from calculate_grant_flows does not list refresh_token despite this being a valid grant flow. The deprecated calculate_token_grant_types method did add refresh_token to the list of configured grant flows.

Without this, code for getting the full list of grant flows supported, such that you can support RFC 8414, is required to be:

  def grant_types_supported
    grant_types_supported = Doorkeeper.configuration.grant_flows.dup
    grant_types_supported << 'refresh_token' if Doorkeeper.configuration.refresh_token_enabled?
    grant_types_supported
  end

Expected behavior

Doorkeeper should expose all configured grant flows via a method, including the refresh_token grant flow

Actual behavior

Doorkeeper does not expose the refresh_token grant flow if refresh tokens are enabled.

System configuration

Doorkeeper initializer:

# config/initializers/doorkeeper.rb
Doorkeeper.configure do
  use_refresh_token
end

Ruby version: 3.3.5

Gemfile.lock: n/a - Doorkeeper @ 5.7.1

@ThisIsMissEm
Copy link
Contributor Author

I did just notice that we have the following in mastodon:

Doorkeeper.configure do
  # ...
  grant_flows %w(authorization_code client_credentials)
  # ...
end

I guess arguably we should add refresh_token into that, however, perhaps the use_refresh_tokens should warn or error if the refresh token grant flow isn't enabled?

@ThisIsMissEm
Copy link
Contributor Author

@ThisIsMissEm
Copy link
Contributor Author

I have just found token_grant_flows which does do the same logic as above, but if you have grant_flows containing refresh_token then the refresh token flow is listed twice (not sure if this would cause problems), but it should probably be made unique

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

No branches or pull requests

1 participant