Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Core/CredentialCacheStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public CredentialCacheStore(IGit git, string options)

#region ICredentialStore

public string Name => "Git Credential Cache";

public IList<string> GetAccounts(string service)
{
// Listing accounts is not supported by the credential-cache store so we just attempt to retrieve
Expand Down
9 changes: 9 additions & 0 deletions src/Core/CredentialStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public CredentialStore(ICommandContext context)

#region ICredentialStore

public string Name
{
get
{
EnsureBackingStore();
return _backingStore.Name;
}
}

public IList<string> GetAccounts(string service)
{
EnsureBackingStore();
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Diagnostics/CredentialStoreDiagnostic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public CredentialStoreDiagnostic(ICommandContext commandContext)

protected override Task<bool> RunInternalAsync(StringBuilder log, IList<string> additionalFiles)
{
log.AppendLine($"ICredentialStore instance is of type: {CommandContext.CredentialStore.GetType().Name}");
log.AppendLine($"Credential store is: {CommandContext.CredentialStore.Name}");

// Create a service that is guaranteed to be unique
string service = $"https://example.com/{Guid.NewGuid():N}";
Expand Down
5 changes: 5 additions & 0 deletions src/Core/ICredentialStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace GitCredentialManager
/// </summary>
public interface ICredentialStore
{
/// <summary>
/// Get the name of the credential store.
/// </summary>
string Name { get; }

/// <summary>
/// Get all accounts from the store for the given service.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Interop/Linux/SecretServiceCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public SecretServiceCollection(string @namespace)

#region ICredentialStore

public string Name => "freedesktop.org Secret Service";

public IList<string> GetAccounts(string service)
{
return Enumerate(service, null).Select(x => x.Account).Distinct().ToList();
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Interop/MacOS/MacOSKeychain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public MacOSKeychain(string @namespace = null)

#region ICredentialStore

public string Name => "macOS Keychain";

public IList<string> GetAccounts(string service)
{
IntPtr query = IntPtr.Zero;
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Interop/Posix/GpgPassCredentialStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public GpgPassCredentialStore(IFileSystem fileSystem, IGpg gpg, string storeRoot
_gpg = gpg;
}

public override string Name => "GPG/Pass";

protected override string CredentialFileExtension => ".gpg";

private string GetGpgId(string credentialFullPath)
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Interop/Windows/DpapiCredentialStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public DpapiCredentialStore(IFileSystem fileSystem, string storeRoot, string @na
PlatformUtils.EnsureWindows();
}

public override string Name => "DPAPI";

protected override bool TryDeserializeCredential(string path, out FileCredential credential)
{
string text;
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Interop/Windows/WindowsCredentialManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public WindowsCredentialManager(string @namespace = null)
_namespace = @namespace;
}

public string Name => "Windows Credential Manager";

public IList<string> GetAccounts(string service)
{
return Enumerate(service, null).Select(x => x.UserName).Distinct().ToList();
Expand Down
2 changes: 2 additions & 0 deletions src/Core/NullCredentialStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace GitCredentialManager;
/// </summary>
public class NullCredentialStore : ICredentialStore
{
public string Name => "No-op";

public IList<string> GetAccounts(string service) => Array.Empty<string>();

public ICredential Get(string service, string account) => null;
Expand Down
2 changes: 2 additions & 0 deletions src/Core/PlaintextCredentialStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public PlaintextCredentialStore(IFileSystem fileSystem, string storeRoot, string
protected string Namespace { get; }
protected virtual string CredentialFileExtension => ".credential";

public virtual string Name => "Plaintext";

public IList<string> GetAccounts(string service)
{
return Enumerate(service, null).Select(x => x.Account).Distinct().ToList();
Expand Down
2 changes: 2 additions & 0 deletions src/TestInfrastructure/Objects/TestCredentialStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public TestCredentialStore()

#region ICredentialStore

public string Name => "Test Credential Store";

public IList<string> GetAccounts(string service)
{
return Query(service, null).Select(x => x.Account).Distinct().ToList();
Expand Down
Loading