Enum Credential

Source
pub enum Credential {
    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>,
    },
}
Expand description

Represents different types of credentials that can be used for authentication.

Variants§

§

Password

Username and password credentials

Fields

§username: String
§password: String
§

OAuth

OAuth authorization code flow

Fields

§authorization_code: String
§redirect_uri: Option<String>
§code_verifier: Option<String>
§

OAuthRefresh

OAuth refresh token

Fields

§refresh_token: String
§

ApiKey

API key authentication

Fields

§

Jwt

JSON Web Token

Fields

§token: String
§

Bearer

Bearer token (generic)

Fields

§token: String
§

Basic

Basic authentication (username:password base64 encoded)

Fields

§credentials: String
§

Custom

Custom authentication with flexible key-value pairs

Fields

§method: String
§

Mfa

Multi-factor authentication token

Fields

§primary_credential: Box<Credential>
§mfa_code: String
§challenge_id: String
§

Certificate

Certificate-based authentication

Fields

§certificate: Vec<u8>
§private_key: Vec<u8>
§passphrase: Option<String>
§

Saml

SAML assertion

Fields

§assertion: String
§relay_state: Option<String>
§

OpenIdConnect

OpenID Connect ID token

Fields

§id_token: String
§access_token: Option<String>
§refresh_token: Option<String>

Implementations§

Source§

impl Credential

Source

pub fn password( username: impl Into<String>, password: impl Into<String>, ) -> Self

Create password credentials

Source

pub fn oauth_code(authorization_code: impl Into<String>) -> Self

Create OAuth authorization code credentials

Source

pub fn oauth_code_with_pkce( authorization_code: impl Into<String>, code_verifier: impl Into<String>, ) -> Self

Create OAuth authorization code credentials with PKCE

Source

pub fn oauth_refresh(refresh_token: impl Into<String>) -> Self

Create OAuth refresh token credentials

Source

pub fn api_key(key: impl Into<String>) -> Self

Create API key credentials

Source

pub fn jwt(token: impl Into<String>) -> Self

Create JWT credentials

Source

pub fn bearer(token: impl Into<String>) -> Self

Create bearer token credentials

Source

pub fn basic(username: impl Into<String>, password: impl Into<String>) -> Self

Create basic authentication credentials

Source

pub fn custom(method: impl Into<String>, data: HashMap<String, String>) -> Self

Create custom credentials

Source

pub fn mfa( primary_credential: Credential, mfa_code: impl Into<String>, challenge_id: impl Into<String>, ) -> Self

Create MFA credentials

Source

pub fn certificate( certificate: Vec<u8>, private_key: Vec<u8>, passphrase: Option<String>, ) -> Self

Create certificate credentials

Source

pub fn saml(assertion: impl Into<String>) -> Self

Create SAML assertion credentials

Source

pub fn openid_connect(id_token: impl Into<String>) -> Self

Create OpenID Connect credentials

Source

pub fn credential_type(&self) -> &str

Get the credential type as a string

Source

pub fn supports_refresh(&self) -> bool

Check if this credential supports refresh

Source

pub fn refresh_token(&self) -> Option<&str>

Extract refresh token if available

Source

pub fn is_sensitive(&self) -> bool

Check if this credential is sensitive and should be masked in logs

Source

pub fn safe_display(&self) -> String

Get a safe representation for logging (masks sensitive data)

Trait Implementations§

Source§

impl Clone for Credential

Source§

fn clone(&self) -> Credential

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Credential

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Credential

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Credential

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,