-
Notifications
You must be signed in to change notification settings - Fork 925
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
Oauth2 built-in refresh token #188
Oauth2 built-in refresh token #188
Conversation
@robsontenorio Can we get this functionality for local scheme, too? |
@jonasgrosch Sorry, this is intended for Oauth2 Scheme. For LOCAL Scheme, it would be very similar. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be some mistake on conformance with the OAuth spec.
Also, would you mind adding support of expiring access tokens obtained with the implicit flow (token grant)?
} | ||
|
||
// time variables | ||
const tokenExpiresAt = jwtDecode(token).exp * 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not rely on access token being a JWT, but instead use the expires_in
response returned along with access_token
.
|
||
// time variables | ||
const tokenExpiresAt = jwtDecode(token).exp * 1000 | ||
const refreshTokenExpiresAt = jwtDecode(refreshToken).exp * 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not try to decode the refresh token. A refresh token is normally not a JWT, and it's the case of Auth0.
// Try to refresh token before processing current request | ||
isRefreshing = true | ||
|
||
return $axios.post(this.options.access_token_endpoint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use async-await and when the refresh fails, please log the user out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is safe to return a promise.
|
||
watchTokenExpiration () { | ||
const { $axios } = this.$auth.ctx.app | ||
let isRefreshing = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use (and wait for) a shared Promise instead of a boolean flag.
Refresh token is a much needed feature. So either this or #208 would be super awesome to have! |
Closing in favor of #208 |
any documentation of that feature? my backend returns
how to handle with that |
It was not approved/merged, just closed. See #208 |
@robsontenorio sorry for the late review. This will be hopefully shipped with #325. |
@robsontenorio We may extract shared functionalities and share them between oauth and local. |
@MathiasCiarlo We need some refactors but don't want to block shipping other fixes for refresh support. Let's see what happens but if not included in 4.6, 4.7 or 5.0 will be worked right after that. |
@pi0 Another one :)
Automatically refresh the "token" if it expires, because some Oauth providers has a short token TTL. It just intercepts axios requests, check for token expiration and try to refresh it.
Solves #148