#systemd-service #credentials #loading #helping #load #path #trailing #white-space

secretfile

A small library for helping with loading secrets from files including systemd service credentials support

2 releases

0.1.1 May 22, 2025
0.1.0 Feb 29, 2024

#925 in Authentication

Download history 43/week @ 2025-02-06 38/week @ 2025-02-13 21/week @ 2025-02-20 36/week @ 2025-02-27 21/week @ 2025-03-06 54/week @ 2025-03-13 24/week @ 2025-03-20 20/week @ 2025-03-27 2/week @ 2025-04-03 27/week @ 2025-04-10 12/week @ 2025-04-17 45/week @ 2025-04-24 22/week @ 2025-05-01 21/week @ 2025-05-08 6/week @ 2025-05-15 155/week @ 2025-05-22

208 downloads per month

MIT/Apache

4KB

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.

No runtime deps