Struct imagevault::authentication::ClientCredentialsAuthentication[][src]

pub struct ClientCredentialsAuthentication {
    pub access_token: Option<String>,
    pub valid_to: Option<Instant>,
    pub impersonate_as: Option<String>,
    pub roles: Option<Vec<String>>,
}

Fields

access_token: Option<String>valid_to: Option<Instant>impersonate_as: Option<String>roles: Option<Vec<String>>

Implementations

Creates a new ClientCredentialAuthentication

Arguments

  • impersonate_as - The user (if any) the client should impersonate
  • roles - A list of roles (if any) that the client should impersonate

Example

use imagevault::authentication::ClientCredentialsAuthentication;

// No impersonation
// Can also use ClientCredentialsAuthentication::default()
let auth = ClientCredentialsAuthentication::new(None, None);

// Impersonates user JohnD
let auth = ClientCredentialsAuthentication::new(
    Some("JohnD"),
    None
);

// Impersonates user JohnD and roles Admin and SuperAdmin
let auth = ClientCredentialsAuthentication::new(
    Some("JohnD"),
    Some(vec!["Admin", "SuperAdmin"])
);

Trait Implementations

Authenticate is called from the ImageVault Client whenever a request requiring authentication is made. It shouldn’t be called directly. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.