Skip to main content

SplitFileCredentialsProvider

Struct SplitFileCredentialsProvider 

Source
pub struct SplitFileCredentialsProvider { /* private fields */ }
Expand description

Reads the credentials for the resource owner and the client from two seperate (mostly) JSON files.

Implementations§

Source§

impl SplitFileCredentialsProvider

Source

pub fn new<C, O, CP, UP>( client_credentials_file_path: C, owner_credentials_file_path: O, client_credentials_parser: CP, owner_credentials_parser: UP, ) -> Self
where C: Into<PathBuf>, O: Into<PathBuf>, CP: ClientCredentialsParser + Send + Sync + 'static, UP: ResourceOwnerCredentialsParser + Send + Sync + 'static,

Create a new instance with the given paths and the given parsers.

Source

pub fn with_default_parsers<C, O>( client_credentials_file_path: C, owner_credentials_file_path: O, ) -> Self
where C: Into<PathBuf>, O: Into<PathBuf>,

Creates a new instance for the given path with default parsers.

§Example files
§Client credentials file:
{
   "client_id" : "<id>",
   "client_secret" : "<secret>"
}
§Resource owner credentials file:
{
   "username" : "<id>",
   "password" : "<secret>"
}
Source

pub fn with_default_client_parser<C, O, P>( client_credentials_file_path: C, owner_credentials_file_path: O, owner_credentials_parser: P, ) -> Self
where C: Into<PathBuf>, O: Into<PathBuf>, P: ResourceOwnerCredentialsParser + Send + Sync + 'static,

Creates a new instance for the given path with a default parser for the client credentials.

§Example files
§Client credentials file:
{
   "client_id" : "<id>",
   "client_secret" : "<secret>"
}
Source

pub fn with_default_client_parser_from_env<P>( owner_credentials_parser: P, ) -> InitializationResult<Self>
where P: ResourceOwnerCredentialsParser + Send + Sync + 'static,

Configures from environment variables while the ResourceOwnerCredentialsParser can be explicitly set.

  • TOKKIT_CREDENTIALS_DIR’: The first place to look for the path to the credentials files.
  • CREDENTIALS_DIR’: The fallback for ‘TOKKIT_CREDENTIALS_DIR
  • TOKKIT_CREDENTIALS_RESOURCE_OWNER_FILENAME’ : The file name for the resource owner credentials
  • TOKKIT_CREDENTIALS_CLIENT_FILENAME’ : The file name for the client credentials

Either ‘TOKKIT_CREDENTIALS_DIR’ or ‘CREDENTIALS_DIR’ must be set where ‘TOKKIT_CREDENTIALS_DIR’ takes preceedence. ‘TOKKIT_CREDENTIALS_RESOURCE_OWNER_FILENAME’ defaults to user.json while ‘TOKKIT_CREDENTIALS_CLIENT_FILENAME’ defaults to client.json.

Source

pub fn with_default_parsers_from_env() -> InitializationResult<Self>

Configures the instance from environment variables.

  • TOKKIT_CREDENTIALS_DIR’: The first place to look for the path to the credentials files.
  • CREDENTIALS_DIR’: The fallback for ‘TOKKIT_CREDENTIALS_DIR
  • TOKKIT_CREDENTIALS_RESOURCE_OWNER_FILENAME’ : The file name for the resource owner credentials
  • TOKKIT_CREDENTIALS_CLIENT_FILENAME’ : The file name for the client credentials

Either ‘TOKKIT_CREDENTIALS_DIR’ or ‘CREDENTIALS_DIR’ must be set where ‘TOKKIT_CREDENTIALS_DIR’ takes preceedence. ‘TOKKIT_CREDENTIALS_RESOURCE_OWNER_FILENAME’ defaults to user.json while ‘TOKKIT_CREDENTIALS_CLIENT_FILENAME’ defaults to client.json.

Trait Implementations§

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> 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> 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, 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<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