Struct SyncScramServer

Source
pub struct SyncScramServer<S: ScramHashing, A: ScramAuthServer<S>, B: ScramCbHelper> { /* 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: ScramAuthServer 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 + 'ss, A: ScramAuthServer<S> + 'ss, B: ScramCbHelper + 'ss> SyncScramServer<S, A, B>

Source

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

Consumes the instance converting it into the ScramServerDyn. 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, A: ScramAuthServer<S>, B: ScramCbHelper> SyncScramServer<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<SyncScramServer<S, A, B>>

Creates new instance of the SyncScramServer by borrowing the scram_auth_serv and chan_bind_helper with lifetime ’ss.

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

  • data_chanbind - A channel binding data TLS Endpoint Cert Hash

  • chan_bind_helper - An implemented trait ScramCbHelper which should provide crate with all necessary data for channel bind.

  • 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 = ScramServer::<ScramSha256, AuthServer, AuthServer>::new(&serv, &serv, nonce, scramtype, false);

Trait Implementations§

Source§

impl<S: Debug + ScramHashing, A: Debug + ScramAuthServer<S>, B: Debug + ScramCbHelper> Debug for SyncScramServer<S, A, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: ScramHashing, A: ScramAuthServer<S>, B: ScramCbHelper> ScramServerDyn for SyncScramServer<S, A, B>

Source§

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

Returnes 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 get_auth_authzid(&self) -> Option<&String>

Returnes the authzid (a=) if 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(&mut self, input: &[u8]) -> ScramResultServer

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

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

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

Auto Trait Implementations§

§

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

§

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

§

impl<S, A, B> Send for SyncScramServer<S, A, B>
where A: Send, B: Send, S: Send,

§

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

§

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

§

impl<S, A, B> UnwindSafe for SyncScramServer<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.