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>
impl<'ss, S: ScramHashing + Sync + Send + 'ss, A: AsyncScramAuthServer<S> + Sync + Send + 'ss, B: AsyncScramCbHelper + Sync + Send + 'ss> AsyncScramServer<S, A, B>
Sourcepub fn make_dyn(self) -> Box<dyn AsyncScramServerDyn + 'ss>
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>
impl<S: ScramHashing + Send, A: AsyncScramAuthServer<S> + Sync + Send, B: AsyncScramCbHelper + Sync + Send> AsyncScramServer<S, A, B>
Sourcepub fn new(
scram_auth_serv: A,
chan_bind_helper: B,
scram_nonce: ScramNonce,
st: &'static ScramType,
ignore_exts: bool,
) -> ScramResult<AsyncScramServer<S, A, B>>
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);
Sourcepub fn get_auth_username(&self) -> Option<&String>
pub fn get_auth_username(&self) -> Option<&String>
Sourcepub async fn parse_response_base64<T>(&mut self, input: T) -> ScramResultServer
pub async fn parse_response_base64<T>(&mut self, input: T) -> ScramResultServer
Decodes the input from base64 and performes parsing and result computation.
§Arguments
input
- A response received from client.
§Returns
- A ScramResultServer is returned.
Sourcepub async fn parse_response(&mut self, resp: &str) -> ScramResultServer
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
- The ScramResultServer is returned.
Trait Implementations§
Source§impl<S: ScramHashing + Send, A: AsyncScramAuthServer<S> + Sync + Send, B: AsyncScramCbHelper + Sync + Send> AsyncScramServerDyn for AsyncScramServer<S, A, B>
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>
fn get_auth_username(&self) -> Option<&String>
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,
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
- The ScramResultServer is returned with the result.
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,
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
- The ScramResultServer is returned with the result.