pub enum Credential {
Show 13 variants
Password {
username: String,
password: String,
},
OAuth {
authorization_code: String,
redirect_uri: Option<String>,
code_verifier: Option<String>,
state: Option<String>,
},
OAuthRefresh {
refresh_token: String,
},
ApiKey {
key: String,
},
Jwt {
token: String,
},
Bearer {
token: String,
},
Basic {
credentials: String,
},
Custom {
method: String,
data: HashMap<String, String>,
},
Mfa {
primary_credential: Box<Credential>,
mfa_code: String,
challenge_id: String,
},
Certificate {
certificate: Vec<u8>,
private_key: Vec<u8>,
passphrase: Option<String>,
},
Saml {
assertion: String,
relay_state: Option<String>,
},
OpenIdConnect {
id_token: String,
access_token: Option<String>,
refresh_token: Option<String>,
},
DeviceCode {
device_code: String,
client_id: String,
},
}Expand description
Represents different types of credentials that can be used for authentication.
Variants§
Password
Username and password credentials
OAuth
OAuth authorization code flow
OAuthRefresh
OAuth refresh token
ApiKey
API key authentication
Jwt
JSON Web Token
Bearer
Bearer token (generic)
Basic
Basic authentication (username:password base64 encoded)
Custom
Custom authentication with flexible key-value pairs
Mfa
Multi-factor authentication token
Certificate
Certificate-based authentication
Saml
SAML assertion
OpenIdConnect
OpenID Connect ID token
DeviceCode
Device flow credentials (device code polling)
Implementations§
Source§impl Credential
impl Credential
Sourcepub fn password(
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn password( username: impl Into<String>, password: impl Into<String>, ) -> Self
Create password credentials
Sourcepub fn oauth_code(authorization_code: impl Into<String>) -> Self
pub fn oauth_code(authorization_code: impl Into<String>) -> Self
Create OAuth authorization code credentials
Sourcepub fn oauth_code_with_pkce(
authorization_code: impl Into<String>,
code_verifier: impl Into<String>,
) -> Self
pub fn oauth_code_with_pkce( authorization_code: impl Into<String>, code_verifier: impl Into<String>, ) -> Self
Create OAuth authorization code credentials with PKCE
Sourcepub fn oauth_refresh(refresh_token: impl Into<String>) -> Self
pub fn oauth_refresh(refresh_token: impl Into<String>) -> Self
Create OAuth refresh token credentials
Sourcepub fn device_code(
device_code: impl Into<String>,
client_id: impl Into<String>,
) -> Self
pub fn device_code( device_code: impl Into<String>, client_id: impl Into<String>, ) -> Self
Create device code credentials for device flow
Sourcepub fn basic(username: impl Into<String>, password: impl Into<String>) -> Self
pub fn basic(username: impl Into<String>, password: impl Into<String>) -> Self
Create basic authentication credentials
Sourcepub fn custom(method: impl Into<String>, data: HashMap<String, String>) -> Self
pub fn custom(method: impl Into<String>, data: HashMap<String, String>) -> Self
Create custom credentials
Sourcepub fn mfa(
primary_credential: Credential,
mfa_code: impl Into<String>,
challenge_id: impl Into<String>,
) -> Self
pub fn mfa( primary_credential: Credential, mfa_code: impl Into<String>, challenge_id: impl Into<String>, ) -> Self
Create MFA credentials
Sourcepub fn certificate(
certificate: Vec<u8>,
private_key: Vec<u8>,
passphrase: Option<String>,
) -> Self
pub fn certificate( certificate: Vec<u8>, private_key: Vec<u8>, passphrase: Option<String>, ) -> Self
Create certificate credentials
Sourcepub fn openid_connect(id_token: impl Into<String>) -> Self
pub fn openid_connect(id_token: impl Into<String>) -> Self
Create OpenID Connect credentials
Sourcepub fn credential_type(&self) -> &str
pub fn credential_type(&self) -> &str
Get the credential type as a string
Sourcepub fn supports_refresh(&self) -> bool
pub fn supports_refresh(&self) -> bool
Check if this credential supports refresh
Sourcepub fn refresh_token(&self) -> Option<&str>
pub fn refresh_token(&self) -> Option<&str>
Extract refresh token if available
Sourcepub fn is_sensitive(&self) -> bool
pub fn is_sensitive(&self) -> bool
Check if this credential is sensitive and should be masked in logs
Sourcepub fn safe_display(&self) -> String
pub fn safe_display(&self) -> String
Get a safe representation for logging (masks sensitive data)
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more