Skip to content

Sets expiry of token generated using refresh_token to that of original token [Fixes #1364] #1366

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

Merged
merged 1 commit into from
Mar 4, 2020

Conversation

rishabhsairawat
Copy link
Contributor

This PR aims to fix #1364 .

See the following example:

Doorkeeper Configuration

Doorkeeper.configure do
  # ...
  access_token_expires_in 3.hours

  custom_access_token_expires_in do |context|
     if context.grant_type == Doorkeeper::OAuth::PASSWORD
        1.hour
     elsif context.grant_type == Doorkeeper::OAuth::AUTHORIZATION_CODE
        2.hours
     end

  end

  use_refresh_token do |context|
     true
  end
  
# ...
end

Behavior without this fix:

  • When refreshing a token(originally created using authorization_code flow having the expiry of 2 hours), the new token will have an expiry of 3 hours.

  • When refreshing a token(originally created using password flow having the expiry of 1 hour), the new token will have an expiry of 3 hours.

Behavior after this fix:

  • When refreshing a token(originally created using authorization_code flow having the expiry of 2 hours), the new token will also have an expiry of 2 hours.

  • When refreshing a token(originally created using password flow having the expiry of 1 hour), the new token will also have an expiry of 1 hour.

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.

🚝

thanks @rishabhsairawat !

@nbulaj nbulaj merged commit e523c64 into doorkeeper-gem:master Mar 4, 2020
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.

Wrong behavior in refreshing a token
2 participants