Expand description
SASL Provider context
This is the central type required to use SASL both for protocol implementations requiring the use of SASL and for users wanting to provide SASL authentication to such implementations.
This struct is not Clone
or Copy
, but all functions required for authentication exchanges
only need a non-mutable reference to it. If you want to do several authentication exchanges in
parallel, e.g. in a server context, you can wrap it in an std::sync::Arc
to add cheap
cloning.
Fields
callback: Option<Arc<dyn Callback + Send + Sync>>
Implementations
sourceimpl SASL
impl SASL
pub fn build() -> Builder
pub fn new() -> Self
sourcepub fn init(&mut self)
pub fn init(&mut self)
Initialize this SASL with the builtin Mechanisms
Calling this function is usually not necessary if you’re using the registry_static
feature since the builtin mechanisms are registered at compile time then. However the
optimizer may strip modules that it deems are unused so a call may still be necessary but
it then extremely cheap.
pub fn install_callback(&mut self, callback: Arc<dyn Callback + Send + Sync>)
sourceimpl SASL
impl SASL
Provider functions
These methods are only available when compiled with feature provider
or provider_base64
(enabled by default).
They are mainly relevant for protocol implementations wanting to start an
authentication exchange.
sourcepub fn client_mech_list(
&self
) -> impl IntoIterator<Item = &'static Mechanism> + '_
pub fn client_mech_list(
&self
) -> impl IntoIterator<Item = &'static Mechanism> + '_
Returns the list of client mechanisms supported by this provider.
An interactive client “logging in” to some server application would use this method. The
server application would use SASL::server_mech_list()
.
sourcepub fn server_mech_list(
&self
) -> impl IntoIterator<Item = &'static Mechanism> + '_
pub fn server_mech_list(
&self
) -> impl IntoIterator<Item = &'static Mechanism> + '_
Returns the list of Server Mechanisms supported by this provider.
An server allowing client software to “log in” would use this method. A client
application would use SASL::client_mech_list()
.
pub fn client_start_suggested<'a>(
&self,
mechs: impl IntoIterator<Item = &'a Mechname>
) -> Result<Session, SASLError>
pub fn server_start_suggested<'a>(
&self,
mechs: impl IntoIterator<Item = &'a Mechname>
) -> Result<Session, SASLError>
sourcepub fn client_supports(&self, mech: &Mechname) -> bool
pub fn client_supports(&self, mech: &Mechname) -> bool
Returns whether there is client-side support for the given mechanism.
You should not call this function to filter supported mechanisms if you intend to start a
session right away since this function only calls self.client_start()
with the given
Mechanism name and throws away the Session.
sourcepub fn server_supports(&self, mech: &Mechname) -> bool
pub fn server_supports(&self, mech: &Mechname) -> bool
Returns whether there is server-side support for the specified mechanism
You should not call this function to filter supported mechanisms if you intend to start a
session right away since this function only calls self.server_start()
with the given
Mechanism name and throws away the Session.
sourcepub fn new_session(
&self,
mechdesc: &'static Mechanism,
mechanism: Box<dyn Authentication>,
side: Side
) -> Session
pub fn new_session(
&self,
mechdesc: &'static Mechanism,
mechanism: Box<dyn Authentication>,
side: Side
) -> Session
Start a new session with the given Authentication
implementation
This function should rarely be necessary, see SASL::client_start
and
SASL::server_start
for more ergonomic alternatives.
sourcepub fn client_start(&self, mech: &Mechname) -> Result<Session, SASLError>
pub fn client_start(&self, mech: &Mechname) -> Result<Session, SASLError>
Starts a authentication exchange as a client
Depending on the mechanism chosen this may need additional data from the application, e.g.
an authcid, optional authzid and password for PLAIN. To provide that data an application
has to either call set_property
before running the step that requires the data, or
install a callback.
sourcepub fn server_start(&self, mech: &Mechname) -> Result<Session, SASLError>
pub fn server_start(&self, mech: &Mechname) -> Result<Session, SASLError>
Starts a authentication exchange as the server role
An application acting as server will most likely need to implement a callback to check the authentication data provided by the user.
See Callback on how to implement callbacks.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for SASL
impl Send for SASL
impl Sync for SASL
impl Unpin for SASL
impl !UnwindSafe for SASL
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more