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

fix: #1802 confirm cached credential before rejecting #1803

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

tyrielv
Copy link
Contributor

@tyrielv tyrielv commented Jan 26, 2024

Issue
When GCM is in OAuth mode, rejecting the credential is equivalent to a sign-out request, which means the next attempt to get a credential will always cause a pop-up. See #1802

** Changes **
Before rejecting a credential try getting the credential from GCM again.
If GCM still returns the same credential, then tell GCM to reject it.
If GCM returns a different credential, don't attempt to reject the previous one - just return and let the caller try the new credential instead.

@tyrielv
Copy link
Contributor Author

tyrielv commented Jan 26, 2024

@microsoft-github-policy-service agree company="Microsoft"

Copy link
Contributor

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few nits based on the repo style guide, but they aren't critical.

Also, I merged your change with mine in #1804 to make sure that everything built, passed unit tests, and ran against a full production repo just fine. The merge is in derrickstolee:oath-change-2024.

I'm currently running the default functional test suite as an extra precaution, but I don't anticipate that this change will have any effect because the test suite operates against a public repo and thus does not test the auth stack in any way.

You may also want to cherry-pick abcb73f since that will set the default mode to oauth, giving us faster adoption of the mode in VFS for Git customers.

@@ -91,9 +91,27 @@ public void RejectCredentials(ITracer tracer, string credentialString)
{
lock (this.gitAuthLock)
{
var cachedCredentialAtStartOfReject = this.cachedCredentialString;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The norm in this repo is to not use var unless the right-hand-side is a constructor explicitly mentioning the type that the variable will become.

Suggested change
var cachedCredentialAtStartOfReject = this.cachedCredentialString;
string cachedCredentialAtStartOfReject = this.cachedCredentialString;

{
// We can't assume that the credential store's cached credential is the same as the one we have.
// Reload the credential from the store to ensure we're rejecting the correct one.
var attemptsBeforeCheckingExistingCredential = this.numberOfAttempts;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The norm in this repo is to not use var unless the right-hand-side is a constructor explicitly mentioning the type that the variable will become.

Suggested change
var attemptsBeforeCheckingExistingCredential = this.numberOfAttempts;
int attemptsBeforeCheckingExistingCredential = this.numberOfAttempts;

tyrielv and others added 2 commits February 15, 2024 08:51
To more rapidly adopt OAuth tokens, set that as the default for GVFS
repos. This will update on mount, so all users will update to this mode
when they upgrade to a version including this commit.

This may cause some initial frustration as the first time I ran a fetch
in OAuth mode my local clone had a failure with GCM and defaulted to
username/password checks over command line. The second fetch worked just
fine, though.
@tyrielv
Copy link
Contributor Author

tyrielv commented Feb 15, 2024

@derrickstolee Feedback taken

@vdye vdye merged commit 55ba68d into microsoft:master Mar 12, 2024
5 checks passed
@vdye vdye mentioned this pull request Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants