Struct ddmw_client::auth::Auth [−][src]
pub struct Auth {
pub name: Option<String>,
pub pass_file: Option<String>,
pub pass: Option<String>,
pub token_file: Option<String>,
pub token: Option<String>,
}Expand description
Authentication context used to signal how to authenticate a connection.
Fields
name: Option<String>Account name used to authenticate.
pass_file: Option<String>Load raw account passphrase from the specified filename.
pass: Option<String>Raw account passphrase to authenticate with. Only used if name has
been set.
token_file: Option<String>Use the specified file for authentication token storage.
token: Option<String>Authentication token.
Implementations
Return true if there’s either a raw passphrase set in pass or a
passphrase file has beeen set in pass_file. This function does not
validate if the passphrase file exists or is accessible.
Get passphrase.
Return the raw pass field if set. Otherwise, load the pass_file if
set, and return error if the passphrase could not be loaded from the
file.
If neither pass nor pass_file have been set, return an error.
Get authentication token.
Return the raw token field if set. Otherwise, check if token_file is
set. If it is, then attempt to load the token from it. If the file
does not exist, then:
- Return
Ok(None)if account name and pass(file) have been set. - Return error if account name has not been set.
Helper function for authenticating a connection.
Authenticates the connection specified in conn, using the credentials
stored in the Auth buffer using the following logic:
- If a raw token has been supplied in the
tokenfield, then attempt to authenticate with it and return the results. - If a
token_filehas been been set, then:- If the file exists, try to load the authentication token, authenticate with it, and return the results.
- If the file does not exist, then:
- If account name and/or passphrase have not been set, then return error.
- If account name and passphrase have been set, then continue.
- Make sure that an account name and a passphrase has been set.
The passphrase is either set from the
passfield or by loading the contents of the file inpass_file. Return error account name or passphrase can not be acquired. - Authenticate using account name and passphrase. If a
token_filewas specified, then request an authentication token and store it intoken_fileon success. Return error on failure.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Auth
impl UnwindSafe for Auth
Blanket Implementations
Mutably borrows from an owned value. Read more