Skip to content

Commit f8ac4e4

Browse files
authored
Merge pull request #134 from mjcheetham/github-samlsso
github: store the PAT on 'get' request for SAML SSO
2 parents 86290d7 + 22819a0 commit f8ac4e4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/shared/GitHub/GitHubHostProvider.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,16 @@ public override async Task<ICredential> GenerateCredentialAsync(InputArguments i
8989
switch (promptResult.AuthenticationMode)
9090
{
9191
case AuthenticationModes.Basic:
92-
return await GeneratePersonalAccessTokenAsync(targetUri, promptResult.BasicCredential);
92+
ICredential patCredential = await GeneratePersonalAccessTokenAsync(targetUri, promptResult.BasicCredential);
93+
// HACK: Store the PAT immediately in case this PAT is not valid for SSO.
94+
// We don't know if this PAT is valid for SAML SSO and if it's not Git will fail
95+
// with a 403 and call neither 'store' or 'erase'. The user is expected to fiddle with
96+
// the PAT permissions manually on the web and then retry the Git operation.
97+
// We must store the PAT now so they can resume/repeat the operation with the same,
98+
// now SSO authorized, PAT.
99+
// See: https://github.com/microsoft/Git-Credential-Manager-Core/issues/133
100+
Context.CredentialStore.AddOrUpdate(GetCredentialKey(input), patCredential);
101+
return patCredential;
93102

94103
case AuthenticationModes.OAuth:
95104
return await GenerateOAuthCredentialAsync(targetUri);

0 commit comments

Comments
 (0)