#docker #credential #container

docker_credential

Reads a user's docker credentials from config

3 stable releases

1.1.0 Nov 26, 2022
1.0.1 Apr 16, 2019
1.0.0 Apr 15, 2019

#127 in Authentication

Download history 738/week @ 2022-08-14 705/week @ 2022-08-21 778/week @ 2022-08-28 873/week @ 2022-09-04 272/week @ 2022-09-11 208/week @ 2022-09-18 390/week @ 2022-09-25 338/week @ 2022-10-02 325/week @ 2022-10-09 645/week @ 2022-10-16 714/week @ 2022-10-23 328/week @ 2022-10-30 356/week @ 2022-11-06 423/week @ 2022-11-13 566/week @ 2022-11-20 512/week @ 2022-11-27

1,869 downloads per month
Used in oci-distribution

MIT/Apache

15KB
299 lines

docker_credential

Build Status Latest version Documentation

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

Parses a docker config.json either at the loction 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.6MB
~35K SLoC