-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
*: update refresh tokens instead of deleting and creating another #757
Conversation
2c8753e
to
3ee1d92
Compare
3ee1d92
to
13b5649
Compare
rebase for good measure. |
13b5649
to
98c7ed7
Compare
There was a conflict with #767. Rebased, updated to include the fix, and ran the Kubernetes integration tests. |
98c7ed7
to
2ecb196
Compare
@rithujohn191 please take a look |
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.
Everything LGTM. Just had a small doubt.
@@ -273,6 +268,10 @@ func (a *app) handleCallback(w http.ResponseWriter, r *http.Request) { | |||
oauth2Config := a.oauth2Config(nil) | |||
switch { | |||
case code != "": | |||
if state := r.FormValue("state"); state != exampleAppState { |
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.
Just wondering if there is a reason why we should not perform this check for "state" in case of 'refresh'
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.
"state" is only part of a auth code response[0]. it's not part of a refresh event.
I think it's confusing because we're handling both the auth request redirect response (GET) and a frontend post to re-render the page (POST). Maybe we should switch this so GETs and POSTs are what determine the course of action? e.g.
switch r.Method {
case "GET":
// ... handle state and do code exchange
case "POST":
// ... try to refresh token
}
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.
Yes that would definitely make the flow more clear
2ecb196
to
0f5ce72
Compare
@rithujohn191 Updated the example-app. |
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.
Thanks.
Might need a rebase? |
The server implements a strategy called "Refresh Token Rotation" to ensure refresh tokens can only be claimed once. ref: https://tools.ietf.org/html/rfc6819#section-5.2.2.3 Previously "refresh_token" values in token responses where just the ID of the internal refresh object. To implement rotation, when a client redeemed a refresh token, the object would be deleted, a new one created, and the new ID returned as the new "refresh_token". However, this means there was no consistent ID for refresh tokens internally, making things like foreign keys very hard to implement. This is problematic for revocation features like showing all the refresh tokens a user or client has out. This PR updates the "refresh_token" to be an encoded protobuf message, which holds the internal ID and a nonce. When a refresh token is used, the nonce is updated to prevent reuse, but the ID remains the same. Additionally it adds the timestamp of each token's last use.
0f5ce72
to
ed20fee
Compare
The server implements a strategy called "Refresh Token Rotation" to
ensure refresh tokens can only be claimed once.
ref: https://tools.ietf.org/html/rfc6819#section-5.2.2.3
Previously "refresh_token" values in token responses where just the
ID of the internal refresh object. To implement rotation, when a
client redeemed a refresh token, the object would be deleted, a new
one created, and the new ID returned as the new "refresh_token".
However, this means there was no consistent ID for refresh tokens
internally, making things like foreign keys very hard to implement.
This is problematic for revocation features like showing all the
refresh tokens a user or client has out.
This PR updates the "refresh_token" to be an encoded protobuf
message, which holds the internal ID and a nonce. When a refresh
token is used, the nonce is updated to prevent reuse, but the ID
remains the same. Additionally it adds the timestamp of each
token's last use.
cc @rithujohn191