#docker #credential #container

docker_credential

Reads a user's docker credentials from config

5 stable releases

1.2.1 Nov 23, 2023
1.2.0 Mar 22, 2023
1.1.0 Nov 26, 2022
1.0.1 Apr 16, 2019
1.0.0 Apr 15, 2019

#172 in Authentication

Download history 1604/week @ 2023-10-29 1002/week @ 2023-11-05 814/week @ 2023-11-12 1065/week @ 2023-11-19 861/week @ 2023-11-26 729/week @ 2023-12-03 1266/week @ 2023-12-10 1052/week @ 2023-12-17 259/week @ 2023-12-24 544/week @ 2023-12-31 1181/week @ 2024-01-07 1307/week @ 2024-01-14 1487/week @ 2024-01-21 1619/week @ 2024-01-28 1278/week @ 2024-02-04 1144/week @ 2024-02-11

5,595 downloads per month
Used in 3 crates

MIT/Apache

16KB
310 lines

docker_credential

Latest version Documentation

A Rust library for reading a user's Docker 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

~1–1.8MB
~38K SLoC