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

Refresh token allowed as Access Token #391

Closed
rafollett opened this issue Oct 18, 2018 · 5 comments
Closed

Refresh token allowed as Access Token #391

rafollett opened this issue Oct 18, 2018 · 5 comments

Comments

@rafollett
Copy link

Passing the refresh token instead of the access token when using JWT seems to be accepted. I added an "else" case to the if(expiry) check in RestAuthenticationProvider to throw an exception in this case, since this seems to be a security vulnerability (since refresh token does not expire). If my understanding of JWT is incorrect here, please let me know, but thought this would be an improvement to the otherwise great plugin.

@vishnuaggarwal23
Copy link

vishnuaggarwal23 commented Mar 7, 2019

Hi team,
Is there any update on this. Since, what is as per my understanding too, the refresh-token should not be able to be used as an access-token and they should have an expiry associated with them or, there should be mechanism provided to revoke the refresh-token if at all it is needed.

@longwa
Copy link
Contributor

longwa commented Aug 27, 2019

Adding an expiration to the refresh token would break the current plugin as the code specifically uses:

boolean isRefreshToken = jwt.JWTClaimsSet.expirationTime == null

to check if it is doing a refresh or not.

I agree, it seems like those are two separate concerns. The refresh token should probably just have a claim that indicates specifically it is for refresh. Or the loadbyUserName could just take an optional flag indicating it's a refresh operation.

@longwa
Copy link
Contributor

longwa commented Aug 28, 2019

I tested this as well locally and can confirm that you can replace the access_token with the refresh_token and use it to authenticate successfully.

The best solution might be to have the AbstractJwtTokenGenerator.generateRefreshToken method add a claim to the refresh_token that it generates indicating that it is a refresh token.

That would allow the refresh token to have a configurable expiration date (if desired) and still be identified as a refresh_token via the custom claim.

I can fix this and submit a PR

@alvarosanchez
Copy link
Contributor

Adding a custom claim sounds good to me

longwa added a commit to longwa/grails-spring-security-rest that referenced this issue Aug 29, 2019
alvarosanchez added a commit that referenced this issue Aug 30, 2019
Issue #391 - Don't allow refresh_token for auth; Add refreshExpiration
@6footgeek
Copy link

@alvarosanchez Any update on this? I see you merged a fix but it never passed the build :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants