Interface CredentialStore

Common credential-store interface.

interface CredentialStore;

Use this type when application logic should not care whether credentials are stored by Linux, Windows, macOS, an encrypted vault or a test store.

Every store belongs to one CredentialNamespace and returns CredentialHandle values that can be persisted in normal application settings.

Properties

NameTypeDescription
capabilities[get] StoreCapabilitiesDescribe how this store behaves.
credentialNamespace[get] CredentialNamespaceApplication namespace this store belongs to.

Methods

NameDescription
remove (handle) Remove a saved credential.
save (secret, handle) Save a new credential.
update (handle, replacement) Replace the value of an existing credential.
withSecret (handle, callback) Use a saved credential.

Examples

CredentialHandle handle;

auto status = store.save(secret, handle);

if (status == CredentialStatus.ok)
{
    status = store.withSecret(
        handle,
        (scope const(ubyte)[] bytes) @safe
        {
            // Use the credential here.
        }
    );
}