/// Authenticate a user given the AuthDetails provided and return a token
Authenticate a user given the AuthDetails provided and return a token
Authenticate a user given the AuthDetails provided and return a token
pub async fn login(&self, opts: AuthDetails) -> Result<String> {
        match opts {
            AuthDetails::Ldap { path, mut username, mut password } => {
                if username.is_empty() {
                    username = prompt_for_input("Please enter Vault LDAP username: ").await?;
                }
                if password.is_empty() {
                    password = prompt_for_hidden_input("Please enter Vault LDAP password: ").await?;
                }
                let path = path.unwrap_or_else(|| "ldap".to_owned());
                self.login_ldap(&path, &username, &password).await
            },
            AuthDetails::UserPass { path, mut username, mut password } => {
                if username.is_empty() {
                    username = prompt_for_input("Please enter Vault username: ").await?;
                }
                if password.is_empty() {
                    password = prompt_for_hidden_input("Please enter Vault password: ").await?;
                }
                let path = path.unwrap_or_else(|| "userpass".to_owned());
                self.login_userpass(&path, &username, &password).await
            },
            AuthDetails::Token { mut token } => {
                if token.is_empty() {
                    token = prompt_for_hidden_input("Please enter Vault token: ").await?;
                }
                Ok(token)
            }
        }
    }
pub async fn login ( & self , opts : AuthDetails ) -> Result < String > { match opts { AuthDetails :: Ldap { path , mut username , mut password } => { if username . is_empty ( ) { username = prompt_for_input ( " " ) . await ? ; } if password . is_empty ( ) { password = prompt_for_hidden_input ( " " ) . await ? ; } let path = path . unwrap_or_else ( | | " " . to_owned ( ) ) ; self . login_ldap ( & path , & username , & password ) . await } , AuthDetails :: UserPass { path , mut username , mut password } => { if username . is_empty ( ) { username = prompt_for_input ( " " ) . await ? ; } if password . is_empty ( ) { password = prompt_for_hidden_input ( " " ) . await ? ; } let path = path . unwrap_or_else ( | | " " . to_owned ( ) ) ; self . login_userpass ( & path , & username , & password ) . await } , AuthDetails :: Token { mut token } => { if token . is_empty ( ) { token = prompt_for_hidden_input ( " " ) . await ? ; } Ok ( token ) } } }
Authenticate a user given the AuthDetails provided and return a token
Authenticate a user given the AuthDetails provided and return a token
&self
opts
AuthDetails