oci_client/
secrets.rs

1//! Types for working with registry access secrets
2
3/// A method for authenticating to a registry
4#[derive(Eq, PartialEq, Debug, Clone)]
5pub enum RegistryAuth {
6    /// Access the registry anonymously
7    Anonymous,
8    /// Access the registry using HTTP Basic authentication
9    Basic(String, String),
10    /// Access the registry using Bearer token authentication
11    Bearer(String),
12}
13
14pub(crate) trait Authenticable {
15    fn apply_authentication(self, auth: &RegistryAuth) -> Self;
16}
17
18impl Authenticable for reqwest::RequestBuilder {
19    fn apply_authentication(self, auth: &RegistryAuth) -> Self {
20        match auth {
21            RegistryAuth::Anonymous => self,
22            RegistryAuth::Basic(username, password) => self.basic_auth(username, Some(password)),
23            RegistryAuth::Bearer(token) => self.bearer_auth(token),
24        }
25    }
26}