bollard_next/
auth.rs

1//! Credentials management, for access to the Docker Hub or a custom Registry.
2
3use base64::{engine::general_purpose::STANDARD, Engine};
4use serde_derive::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
8#[allow(missing_docs)]
9/// DockerCredentials credentials and server URI to push images using the [Push Image
10/// API](crate::Docker::push_image()) or the [Build Image
11/// API](../struct.Docker.html#method.build_image).
12pub struct DockerCredentials {
13    pub username: Option<String>,
14    pub password: Option<String>,
15    pub auth: Option<String>,
16    pub email: Option<String>,
17    pub serveraddress: Option<String>,
18    pub identitytoken: Option<String>,
19    pub registrytoken: Option<String>,
20}
21
22pub(crate) enum DockerCredentialsHeader {
23    /// Credentials of a single registry sent as an X-Registry-Auth header
24    Auth(Option<DockerCredentials>),
25    /// Credentials of multiple registries sent as an X-Registry-Config header
26    Config(Option<HashMap<String, DockerCredentials>>),
27}
28
29pub(crate) fn base64_url_encode(payload: &str) -> String {
30    STANDARD.encode(payload)
31}