pub struct AuthClient { /* private fields */ }
Expand description
C3A Authentication & Authorization Client.
Implementations§
Source§impl AuthClient
impl AuthClient
Sourcepub async fn new(
app_name: impl ToString,
app_keypair: SignKeypair,
authnz_base_url: impl ToString,
) -> MResult<Self>
pub async fn new( app_name: impl ToString, app_keypair: SignKeypair, authnz_base_url: impl ToString, ) -> MResult<Self>
Create C3A client.
This method ensures that C3A server is alive by health check.
Changes default cookie names.
Sourcepub fn change_challenge_header_names(&mut self, new_names: [&'static str; 3])
pub fn change_challenge_header_names(&mut self, new_names: [&'static str; 3])
Changes default challenge header names.
Sourcepub async fn get_config(&mut self) -> MResult<AppAuthConfiguration>
pub async fn get_config(&mut self) -> MResult<AppAuthConfiguration>
Checks if the application exists in C3A server and returns application config.
Sourcepub async fn app_register(
&self,
invite: Invite,
config: AppAuthConfiguration,
) -> MResult<()>
pub async fn app_register( &self, invite: Invite, config: AppAuthConfiguration, ) -> MResult<()>
Registers the application with given invite code and config.
Sourcepub async fn update_config(
&mut self,
actual_config: &AppAuthConfiguration,
) -> MResult<()>
pub async fn update_config( &mut self, actual_config: &AppAuthConfiguration, ) -> MResult<()>
Edits appliaction config.
Source§impl AuthClient
impl AuthClient
Sourcepub async fn prepare_sign_up(
&self,
login: Id,
) -> MResult<(PreregistrationRequirementsResponse, String)>
pub async fn prepare_sign_up( &self, login: Id, ) -> MResult<(PreregistrationRequirementsResponse, String)>
Prepares a user registration and returns requirements and registration state.
For successful registration you should provide given registration state in perform_sign_up
method.
Sourcepub async fn perform_sign_up(
&self,
login: Id,
state: String,
authentication_flows: AuthenticationFlows,
cli_pkey: Option<Vec<u8>>,
cba_challenge_sign: Option<CBAChallengeSign>,
) -> MResult<TokenBundle>
pub async fn perform_sign_up( &self, login: Id, state: String, authentication_flows: AuthenticationFlows, cli_pkey: Option<Vec<u8>>, cba_challenge_sign: Option<CBAChallengeSign>, ) -> MResult<TokenBundle>
Performs a user registration with given registration state and returns token triple for authorization.
Sourcepub async fn prepare_login(&self, login: Id) -> MResult<PrefetchLoginResponse>
pub async fn prepare_login(&self, login: Id) -> MResult<PrefetchLoginResponse>
Prepares a user authentication and returns login requirements.
Sourcepub async fn perform_login(
&self,
login: Id,
authentication_flow: AuthenticationFlow,
cli_pkey: Option<Vec<u8>>,
cba_challenge_sign: Option<CBAChallengeSign>,
) -> MResult<TokenBundle>
pub async fn perform_login( &self, login: Id, authentication_flow: AuthenticationFlow, cli_pkey: Option<Vec<u8>>, cba_challenge_sign: Option<CBAChallengeSign>, ) -> MResult<TokenBundle>
Performs a user authentication and returns token triple for authorization.
Sourcepub async fn check_user_exists(&self, user_id: Id) -> MResult<()>
pub async fn check_user_exists(&self, user_id: Id) -> MResult<()>
Checks if the user exists.
Gets user tags.
Edits user tags.
Sourcepub async fn delete_user(&self, user_id: Id) -> MResult<()>
pub async fn delete_user(&self, user_id: Id) -> MResult<()>
Deletes the user.
Authorizes a user by given token triple for given tags.
Sourcepub async fn request_cba_update(
&self,
tokens: TokenBundle,
cba_challenge_state: Option<String>,
cba_challenge_sign: Option<CBAChallengeSign>,
) -> MResult<(CBAUpdateResponse, Option<String>)>
pub async fn request_cba_update( &self, tokens: TokenBundle, cba_challenge_state: Option<String>, cba_challenge_sign: Option<CBAChallengeSign>, ) -> MResult<(CBAUpdateResponse, Option<String>)>
Requests an update for client-based authorization token.
This method is intended to be run twice:
- You should get
cba_challenge
inCBAUpdateResponse
and the signedlmpaat_cba_challenge
to store at client side. - You should set
lmpaat_cba_challenge
and providecba_challenge_sign
from the client.
For successful update client should sign the challenge with the same private key which public part is stored at triple.
Sourcepub async fn perform_logout(&self, bundle: TokenBundle) -> MResult<()>
pub async fn perform_logout(&self, bundle: TokenBundle) -> MResult<()>
Logs a user out by his tokens.
Source§impl AuthClient
impl AuthClient
Sourcepub fn lifetimes(&self) -> TokenLifetimes
pub fn lifetimes(&self) -> TokenLifetimes
Returns token lifetimes.
Sourcepub async fn check_signed_in(
&self,
req: &mut Request,
res: &mut Response,
) -> MResult<ApplicationAuthorizeResponse>
pub async fn check_signed_in( &self, req: &mut Request, res: &mut Response, ) -> MResult<ApplicationAuthorizeResponse>
Just checks if a user is authenticated.
Checks if a user is authorized to given action tags.
Sourcepub async fn update_client_token(
&self,
req: &mut Request,
res: &mut Response,
) -> MResult<OK>
pub async fn update_client_token( &self, req: &mut Request, res: &mut Response, ) -> MResult<OK>
Forces to update client token.
Sourcepub async fn logout(&self, req: &mut Request, res: &mut Response) -> MResult<()>
pub async fn logout(&self, req: &mut Request, res: &mut Response) -> MResult<()>
Requests a logout.
After this, refresh token is no longer available, and access token stays alive up to 15 minutes.
This method sets up token triple to cookies.
Trait Implementations§
Source§impl Clone for AuthClient
impl Clone for AuthClient
Source§fn clone(&self) -> AuthClient
fn clone(&self) -> AuthClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more