#credentials #docker #config-parser #helper #env-var #read

docker_credential

Reads a user's docker credentials from config

10 stable releases

1.3.1 Mar 13, 2024
1.3.0 Mar 6, 2024
1.2.3 Feb 27, 2024
1.2.1 Nov 23, 2023
1.0.1 Apr 16, 2019

#95 in Authentication

Download history 42628/week @ 2024-11-17 42633/week @ 2024-11-24 46023/week @ 2024-12-01 48745/week @ 2024-12-08 48081/week @ 2024-12-15 20997/week @ 2024-12-22 25504/week @ 2024-12-29 45111/week @ 2025-01-05 49005/week @ 2025-01-12 46953/week @ 2025-01-19 49475/week @ 2025-01-26 60782/week @ 2025-02-02 57215/week @ 2025-02-09 58286/week @ 2025-02-16 62749/week @ 2025-02-23 55698/week @ 2025-03-02

236,478 downloads per month
Used in 151 crates (13 directly)

MIT/Apache

20KB
401 lines

docker_credential

Latest version Documentation

A Rust library for reading a user's Docker or Podman credentials from config.

Parses a docker config.json either at the location specified by the $DOCKER_CONFIG environment variable or in $HOME/.docker. If credential helpers or a credential store is configured these will be contacted to retrieve the requested credential.

Usage

Add the following to your cargo.toml:

[dependencies]
docker_credential = "1.0.1"

Then invoke from within your along the lines of:

use docker_credential;
use docker_credential::DockerCredential;

let credential = docker_credential::get_credential("https://index.docker.io/v1/").expect("Unable to retrieve credential");

match credential {
  DockerCredential::IdentityToken(token) => println!("Identity token: {}", token),
  DockerCredential::UsernamePassword(user_name, password) => println!("Username: {}, Password: {}", user_name, password),
};

Dependencies

~0.9–1.8MB
~38K SLoC