mirror of
https://codeberg.org/icewind/secretfile.git
synced 2026-06-03 08:34:10 +02:00
A small library for helping with loading secrets from files including systemd service credentials support
- Rust 80.9%
- Nix 19.1%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| src | ||
| .envrc | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
Secretfile
A small library for helping with loading secrets from files including systemd service credentials support.
Usage
Load a value from a file
fn main() -> Result<(), Box<dyn std::error::Error>> {
let secret = secretfile::load("/path/to/supper/secret/file")?;
println!("{secret}");
Ok(())
}
If the provided path includes the $CREDENTIALS_DIRECTORY placeholder, it will
be replaced with the systemd service credential directory. Any trailing
whitespace will be stripped from the returned secret.
Why make this a library?
While the code is simple enough, I found myself copy-pasting it enough times that it seemed useful to put into a library.