#credentials #docker #container #config-parser #env-var

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

#86 in Authentication

Download history 181/week @ 2023-12-23 426/week @ 2023-12-30 1091/week @ 2024-01-06 1185/week @ 2024-01-13 1391/week @ 2024-01-20 1551/week @ 2024-01-27 1188/week @ 2024-02-03 1105/week @ 2024-02-10 1332/week @ 2024-02-17 2084/week @ 2024-02-24 2901/week @ 2024-03-02 2473/week @ 2024-03-09 2446/week @ 2024-03-16 1590/week @ 2024-03-23 2168/week @ 2024-03-30 1597/week @ 2024-04-06

8,151 downloads per month
Used in 3 crates

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.8–1.6MB
~36K SLoC