Struct AsyncScramServer

Source
pub struct AsyncScramServer<S: ScramHashing + Send, A: AsyncScramAuthServer<S> + Sync + Send, B: AsyncScramCbHelper + Sync + Send> { /* private fields */ }
Expand description

§A Scram Server

S: ScramHashing is picked by the program which will use this crate. This library does not handle manually SCRAM types, so the developer should manually parse the requested type i.e SCRAM-SHA-256 and prepeare the instance correctly.
A: AsyncScramAuthServer is a callback trait for authentification. Developer must attach the ScramAuthServer trait to his authentification implementation.
If client picks SCRAM-SHA-<any>-PLUS then the developer should also provide the data_chanbind argument with the server certificate endpoint i.e native_tls::TlsStream::tls_server_end_point()

Implementations§

Source§

impl<'ss, S: ScramHashing + Sync + Send + 'ss, A: AsyncScramAuthServer<S> + Sync + Send + 'ss, B: AsyncScramCbHelper + Sync + Send + 'ss> AsyncScramServer<S, A, B>

Source

pub fn make_dyn(self) -> Box<dyn AsyncScramServerDyn + 'ss>

Consumes the instance converting it into the AsyncScramServerDyn. So this instance can be stored in the vector.

But, in this case it is required to initialize the instance with the consumed instances, otherwise it will be limited by ’ss lifetime.

Source§

impl<S: ScramHashing + Send, A: AsyncScramAuthServer<S> + Sync + Send, B: AsyncScramCbHelper + Sync + Send> AsyncScramServer<S, A, B>

Source

pub fn new( scram_auth_serv: A, chan_bind_helper: B, scram_nonce: ScramNonce, st: &'static ScramType, ignore_exts: bool, ) -> ScramResult<AsyncScramServer<S, A, B>>

Creates new instance of the AsyncScramServer with lifetime ’ss

§Arguments
  • scram_auth_serv - A reference to the instance which implements AsyncScramAuthServer

  • data_chanbind - A channel binding data TLS Endpoint Cert Hash

  • scram_nonce - A Scram Nonce type

  • st - A type of the scram picked by name from table super::scram_common::SCRAM_TYPES

  • ignore_exts - if set to true ignores the additional data which may appear after the protocol data (i.e extensions which are not supported). If set to false generates an error if any unknown data presents after expected data.

§Examples
let serv = AuthServer::new();
let nonce = ScramNonce::Base64(server_nonce);

let scramtype = ScramCommon::get_scramtype("SCRAM-SHA-256").unwrap();
let scram_res = AsyncScramServer::<ScramSha256, AuthServer, AuthServer>::new(&serv, &serv, nonce, scramtype, false);
Source

pub fn get_auth_username(&self) -> Option<&String>

Exposing the username privided by the client. Can be used to form a log message. On early stages before client sends username, it is not availabel.

§Returns
  • Option
    • Some with ref to username String
    • None if not yet available
Source

pub async fn parse_response_base64<T>(&mut self, input: T) -> ScramResultServer
where T: AsRef<[u8]>,

Decodes the input from base64 and performes parsing and result computation.

§Arguments
  • input - A response received from client.
§Returns
Source

pub async fn parse_response(&mut self, resp: &str) -> ScramResultServer

Performes parsing of the response from client and result computation.
It is assumed that resp is UTF-8 valid sequences

§Arguments
  • resp - A response from client as ref str.

  • to_base - if set to true, will encode response into base64.

§Returns

Trait Implementations§

Source§

impl<S: ScramHashing + Send, A: AsyncScramAuthServer<S> + Sync + Send, B: AsyncScramCbHelper + Sync + Send> AsyncScramServerDyn for AsyncScramServer<S, A, B>

Source§

fn get_auth_username(&self) -> Option<&String>

Exposing the username privided by the client. Can be used to form a log message. On early stages before client sends username, it is not availabel.

§Returns
  • Option
    • Some with ref to username String
    • None if not yet available
Source§

fn parse_response_base64<'life0, 'life1, 'async_trait>( &'life0 mut self, input: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = ScramResultServer> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Decodes the input from base64 and performes parsing and result computation.

§Arguments
  • input - A response from client.
§Returns
Source§

fn parse_response<'life0, 'life1, 'async_trait>( &'life0 mut self, resp: &'life1 str, ) -> Pin<Box<dyn Future<Output = ScramResultServer> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Performes parsing of the response from client and result computation.
It is assumed that resp is UTF-8 valid sequences

§Arguments
  • resp - A response from client as ref str.

  • to_base - if set to true, will encode response into base64.

§Returns

Auto Trait Implementations§

§

impl<S, A, B> Freeze for AsyncScramServer<S, A, B>
where A: Freeze, B: Freeze,

§

impl<S, A, B> RefUnwindSafe for AsyncScramServer<S, A, B>

§

impl<S, A, B> Send for AsyncScramServer<S, A, B>

§

impl<S, A, B> Sync for AsyncScramServer<S, A, B>
where S: Sync,

§

impl<S, A, B> Unpin for AsyncScramServer<S, A, B>
where A: Unpin, B: Unpin, S: Unpin,

§

impl<S, A, B> UnwindSafe for AsyncScramServer<S, A, B>
where A: UnwindSafe, B: UnwindSafe, S: UnwindSafe,

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