Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #47 from Microsoft/osxkeychain_workaround_opt-out
Browse files Browse the repository at this point in the history
Make hardcoded credential-osxkeychain workaround opt-out instead of opt-in
  • Loading branch information
olivierdagenais authored Jul 5, 2016
2 parents 80f51de + 22f8d6d commit 40d668f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class OperationArguments
this.Interactivity = com.microsoft.alm.gitcredentialmanager.Interactivity.Auto;
this.ValidateCredentials = true;
this.WriteLog = false;
this.EraseOsxKeyChain = false;
this.EraseOsxKeyChain = true;

String protocol = null;
String host = null;
Expand Down
46 changes: 21 additions & 25 deletions src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ private void printHelpMessage()
standardOut.println(" `git config --global credential.microsoft.visualstudio.com.authority AAD`");
standardOut.println();
standardOut.println(" eraseosxkeychain Enables a workaround when running on Mac OS X");
standardOut.println(" and using 'Apple Git' (which includes the osxkeychain");
standardOut.println(" and using a version of Git which includes the osxkeychain");
standardOut.println(" credential helper, hardcoded before all other helpers).");
standardOut.println(" The problem is osxkeychain may return expired or");
standardOut.println(" revoked credentials, aborting the Git operation.");
standardOut.println(" The workaround is to preemptively erase from osxkeychain");
standardOut.println(" any Git credentials that can be refreshed or re-acquired");
standardOut.println(" by this credential helper.");
standardOut.println(" Defaults to FALSE. Ignored by Basic authority.");
standardOut.println(" Does nothing if Apple Git on Mac OS X isn't detected.");
standardOut.println(" Defaults to TRUE. Ignored by Basic authority.");
standardOut.println(" Does nothing if osxkeychain on Mac OS X isn't detected.");
standardOut.println();
standardOut.println(" `git config --global credential.microsoft.visualstudio.com.eraseosxkeychain false`");
standardOut.println();
Expand Down Expand Up @@ -437,30 +437,26 @@ public static void store(final OperationArguments operationArguments, final IAut
{
if (operationArguments.EraseOsxKeyChain && Provider.isMac(osName))
{
final String gitResponse = fetchGitVersion(processFactory);
if (gitResponse.contains("Apple Git-"))
// check for the presence of git-credential-osxkeychain by scanning PATH
final File osxkeychainFile = findProgram(pathString, pathSeparator, "git-credential-osxkeychain", fileChecker);
if (osxkeychainFile != null)
{
// check for the presence of git-credential-osxkeychain by scanning PATH
final File osxkeychainFile = findProgram(pathString, pathSeparator, "git-credential-osxkeychain", fileChecker);
if (osxkeychainFile != null)
// erase these credentials from osxkeychain
try
{
// erase these credentials from osxkeychain
try
{
final String program = osxkeychainFile.getAbsolutePath();
final TestableProcess process = processFactory.create(program, "erase");
final ProcessCoordinator coordinator = new ProcessCoordinator(process);
coordinator.print(operationArguments.toString());
coordinator.waitFor();
}
catch (final IOException e)
{
throw new Error(e);
}
catch (final InterruptedException e)
{
throw new Error(e);
}
final String program = osxkeychainFile.getAbsolutePath();
final TestableProcess process = processFactory.create(program, "erase");
final ProcessCoordinator coordinator = new ProcessCoordinator(process);
coordinator.print(operationArguments.toString());
coordinator.waitFor();
}
catch (final IOException e)
{
throw new Error(e);
}
catch (final InterruptedException e)
{
throw new Error(e);
}
}
}
Expand Down

0 comments on commit 40d668f

Please sign in to comment.