-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Store PasswordExpiry and OAuthRefreshToken #1464
base: main
Are you sure you want to change the base?
Store PasswordExpiry and OAuthRefreshToken #1464
Conversation
Add properties ICredential.PasswordExpiryUTC and ICredential.OAuthRefreshToken. These correspond to Git credential attributes password_expiry_utc and oauth_refresh_token, see https://git-scm.com/docs/git-credential#IOFMT. Previously these attributes were silently disarded. Plumb these properties from input to host provider to credential store to output. Credential store support for these attributes is optional, marked by new properties ICredentialStore.CanStorePasswordExpiryUTC and ICredentialStore.CanStoreOAuthRefreshToken. Implement support in CredentialCacheStore, SecretServiceCollection and WindowsCredentialManager. Add method IHostProvider.ValidateCredentialAsync. The default implementation simply checks expiry. Improve implementations of GenericHostProvider and GitLabHostProvider. Previously, GetCredentialAsync saved credentials as a side effect. This is no longer necessary. The workaround to store OAuth refresh tokens under a separate service is no longer necessary assuming CredentialStore.CanStoreOAuthRefreshToken. Querying GitLab to check token expiration is no longer necessary assuming CredentialStore.CanStorePasswordExpiryUTC.
a2425b9
to
a21c066
Compare
a21c066
to
2a14b66
Compare
Windows build ought to be fixed by #1418 |
83c3f3a
to
b59547b
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.
Overall looks good! Most of my comments are small things - the only major issue that I'd need to see updated before approving is not having expiry implemented for Windows Credential Manager.
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.
thank you :)
01fcd91
to
fdd7759
Compare
fdd7759
to
60224e0
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.
Thank you for the updates!
Marshal.FreeHGlobal and Marshal.DestroyStructure
Hi, what is going on with this request? The last time I checked my GitHub
account was suspended.
…On Thu, Jan 2, 2025 at 4:43 PM M Hickford ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/shared/Core/HostProvider.cs
<#1464 (comment)>
:
> + Context.Trace.WriteLine("Existing credential satisfies validation.");
+ return credential;
+ }
+ else
+ {
+ Context.Trace.WriteLine("Existing credential fails validation.");
+ if (credential.OAuthRefreshToken != null)
+ {
+ Context.Trace.WriteLine("Found OAuth refresh token.");
+ input = new InputArguments(input, credential.OAuthRefreshToken);
+ }
+ Context.Trace.WriteLine("Erasing invalid credential...");
+ // Why necessary to erase? We can't be sure that storing a fresh
+ // credential will overwrite the invalid credential, particularly
+ // if the usernames differ.
+ Context.CredentialStore.Remove(service, credential);
Here the whole credential is removed from storage, including any OAuth
refresh token.
Typically GenerateCredentialAsync reauthenticates if OAuth refresh fails
for any reason.
Is improvement possible in the network failure case? I can't see how.
—
Reply to this email directly, view it on GitHub
<#1464 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BKZXMWTCXNISR23CCR3QSYD2IW6H5AVCNFSM6AAAAABQOMKEJGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKMRYGMYTONJYHE>
.
You are receiving this because you commented.Message ID:
***@***.***
com>
|
Limit iterations in GetCredentialAsync
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.
My opinion (feal free to disregard it): it is better not to remove refresh token unnecessary. I understand, that GCM can just reauthenticate, but that require extra, otherwise unnecessary, browser interaction from user, thus providing slightly worse user experience.
Anyways, I have no intentions to spend my time to pursue this. Error rate unlikely would be that hi to bother me that much.
Add properties ICredential.PasswordExpiry and ICredential.OAuthRefreshToken. These correspond to Git credential attributes password_expiry_utc and oauth_refresh_token, see https://git-scm.com/docs/git-credential#IOFMT. Previously these attributes were silently disarded.
Plumb these properties from input to host provider to credential store to output.
Credential store support for these attributes is optional, marked by new properties CredentialStore.CanStorePasswordExpiry and ICredentialStore.CanStoreOAuthRefreshToken. Implement support in CredentialCacheStore, SecretServiceCollection and WindowsCredentialManager.
Add method IHostProvider.ValidateCredentialAsync. The default implementation simply checks expiry. Other implementations might query a server.
Improve implementations of GenericHostProvider and GitLabHostProvider. Previously, GetCredentialAsync saved credentials as a side effect. This is no longer necessary. The workaround to store OAuth refresh tokens under a separate service is no longer necessary assuming CredentialStore.CanStoreOAuthRefreshToken. Querying GitLab to check token expiration is no longer necessary assuming CredentialStore.CanStorePasswordExpiry.
Fixes #1463
Fixes #268