-
Notifications
You must be signed in to change notification settings - Fork 10
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
Automatic device authentication when refresh token is expired #325
Open
adombeck
wants to merge
9
commits into
main
Choose a base branch
from
575-automatic-device-auth-on-expired-refresh-token
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5f4c4c8
to
f346403
Compare
8b1f19c
to
d7dc1a8
Compare
I tested this by applying this patch: commit 49c9c3aeb2d58d7b68cebd816ebb887befb080ca (HEAD -> 575-automatic-device-auth-on-expired-refresh-token)
Author: Adrian Dombeck <[email protected]>
Date: Mon Feb 3 15:36:36 2025 +0100
XXX: Test expired refresh token
diff --git a/internal/broker/broker.go b/internal/broker/broker.go
index 93d0d82..193e2c8 100644
--- a/internal/broker/broker.go
+++ b/internal/broker/broker.go
@@ -810,6 +810,9 @@ func (b *Broker) updateSession(sessionID string, session session) error {
func (b *Broker) refreshToken(ctx context.Context, oauth2Config oauth2.Config, oldToken token.AuthCachedInfo) (token.AuthCachedInfo, error) {
timeoutCtx, cancel := context.WithTimeout(ctx, maxRequestDuration)
defer cancel()
+
+ return token.AuthCachedInfo{}, &oauth2.RetrieveError{ErrorCode: "invalid_grant", ErrorDescription: "AADSTS50173: Refresh token is expired"}
+
// set cached token expiry time to one hour in the past
// this makes sure the token is refreshed even if it has not 'actually' expired
oldToken.Token.Expiry = time.Now().Add(-time.Hour)
|
I created ubuntu/authd#774 to track the "show a message" part. |
d7dc1a8
to
fdb7f96
Compare
fdb7f96
to
a3a8712
Compare
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.
Some considerations, but nothing big...
The firstSelectedMode was set but never used.
The decision which authentication modes are offered is (currently) not provider-specific. Lets make the interface simpler until we actually have a need to make it provider-specific.
In preparation for supporting device authentication as the next auth mode.
For consistency
a3a8712
to
6cd19a6
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When refreshing the token fails because the refresh token is expired, we should automatically start device authentication.
Closes ubuntu/authd#575
UDENG-4911