Skip to main content

Module git_credentials

Module git_credentials 

Source
Expand description

Typed credential store for Git authentication (PAT or SSH key).

Built on top of any SecretsStore implementation, this module provides structured storage for Git credentials. Metadata (name, kind) is stored as JSON in the git_credentials_meta scope, while the actual PAT or SSH key is stored as a secret in the git_credentials scope. Both are keyed by a UUID identifier.

§Example

use zlayer_secrets::{EncryptionKey, PersistentSecretsStore};
use zlayer_secrets::git_credentials::{GitCredentialStore, GitCredentialKind};

let key = EncryptionKey::generate();
let secrets_dir = zlayer_paths::ZLayerDirs::system_default().secrets();
let store = PersistentSecretsStore::open(&secrets_dir, key).await?;
let git_store = GitCredentialStore::new(store);

let cred = git_store.create("GitHub PAT for ci", "ghp_xxxx", GitCredentialKind::Pat).await?;
let value = git_store.get_value(&cred.id).await?;
assert_eq!(value.expose(), "ghp_xxxx");

Structs§

GitCredential
Git authentication credential metadata.
GitCredentialStore
Store for Git authentication credentials.

Enums§

GitCredentialKind
The kind of Git credential.