Expand description
Unified secrets library for Rust.
hasp provides a single Store type that dispatches get / put
/ list / delete / exists to multiple backends addressed by
URL scheme:
aws-sm://region/secret-name— AWS Secrets Manager (featureaws-sm)aws-ssm://region/parameter-name— AWS SSM Parameter Store (featureaws-ssm)env://VAR_NAME— environment variables (featureenv)file:///path/to/secret— local files (featurefile)gcp-sm://project/secret-id?version=3— Google Cloud Secret Manager (featuregcp-sm)azure-kv://vault/secret-name?version=3— Azure Key Vault (featureazure-kv)keyring://service/account— OS keyring (featurekeyring)op://vault/item/field— 1Password CLI (featureop)vault://mount/path?field=key— HashiCorp Vault (featurevault)bw://item/field.path— Bitwarden CLI (featurebw)
Each backend is feature-gated so consumers pay only for the stores they use.
§Example
use hasp::Store;
let store = Store::with_defaults();
let secret = store.get("env://HOME").unwrap();The library boundary type for secret values is secrecy::SecretString.
Backends wrap raw bytes at the earliest possible moment so Debug
output never leaks secret values.
Structs§
- Audit
Event - A redacted audit event.
- Cache
Key - Cache key.
schemeis the URL scheme and is intentionally scheme-namespaced so the same URL string handled by two different backends cannot alias. - Copy
Options - Options for
Store::copy. - Copy
Outcome - Outcome of a successful
copy. - Entry
- A named entry returned by
Backend::list. - EnvBackend
- Stdlib-only backend that reads secrets from environment variables.
- File
Sink - Append-only file sink, one JSON event per line.
- Hardening
Token - Zero-sized witness that hardening has been installed in this process.
- Mitigation
Outcome - Outcome of a single mitigation attempt.
- Noop
Sink - A sink that drops every event. Used to disable audit emission entirely without making the sink itself optional.
- Process
Cache - In-process moka-backed cache of
Arc<SecretString>. - Proxy
Config - Parsed HTTP CONNECT proxy configuration.
- Retry
Backend - Decorator backend that retries transient failures with exponential backoff.
- Stderr
Sink - Writes each event as one JSON line to stderr.
- Store
- Batteries-included secret store.
- Store
Builder - Fluent builder for a
Storewith optional proxy configuration. - Syslog
Sink - Forwards each event to the local syslog daemon via
libc::syslog.
Enums§
- Backend
Failure Kind - Retry-policy classification for
Error::Backend. - Cache
Event - Single-phase cache event classifier. Unlike
Verbthese events have no start/done split — a cache hit is observable in one phase. The label set is closed at the type level so audit consumers can switch on it without parsing. - Cache
Policy - Per-invocation in-process cache policy.
- Diff
Outcome - Result of
Store::compare. - Error
- hasp library-surface errors. Stable across all backends; backend impls map their native error vocabulary into these variants.
- Harden
Refusal - Reasons to refuse to start. These represent active injection signals or privilege configurations a secret-handling CLI must not run under.
- IfExists
- What to do when the destination of a
copyalready holds a value. - Verb
- The verb a
Storeoperation belongs to. Closed set so audit event labels are statically known and cannot be widened by a caller.
Traits§
- Audit
Sink - A sink that consumes
AuditEvents. - Backend
Trait - Unified backend trait for secret stores.
- Expose
Secret - Expose a reference to an inner secret
Functions§
- apply_
mitigations - Apply platform process-hardening best-effort.
- check_
refusal_ conditions - Refuse to start if any injection-style env var is set or the process is running setuid.
- custom_
backend - Wrap an externally-provided backend.
- delete
- Delete a secret using a default
Store. - env
- Create an environment-variable backend.
- exists
- Check whether a secret exists using a default
Store. - get
- Fetch a secret using a default
Store. - harden_
process - Combined entry point: refuse on injection signals, then apply
best-effort mitigations. Returns
Ok(outcomes)on success. - install_
hardening - Install process-level hardening and return a
HardeningToken. - list
- List entries using a default
Store. - put
- Store a secret using a default
Store. - scheme_
from_ url - Extract the scheme prefix from a URL string.
Type Aliases§
- Backend
- Secret
String - Secret string type.