simplify the API regarding authentication
This commit is contained in:
parent
a0685e2dc6
commit
6579ce6563
6 changed files with 99 additions and 19 deletions
|
|
@ -1,6 +1,6 @@
|
|||
//! Provides the SASL "ANONYMOUS" mechanism.
|
||||
|
||||
use sasl::SaslMechanism;
|
||||
use sasl::{SaslMechanism, SaslCredentials, SaslSecret};
|
||||
|
||||
pub struct Anonymous;
|
||||
|
||||
|
|
@ -12,4 +12,13 @@ impl Anonymous {
|
|||
|
||||
impl SaslMechanism for Anonymous {
|
||||
fn name(&self) -> &str { "ANONYMOUS" }
|
||||
|
||||
fn from_credentials(credentials: SaslCredentials) -> Result<Anonymous, String> {
|
||||
if let SaslSecret::None = credentials.secret {
|
||||
Ok(Anonymous)
|
||||
}
|
||||
else {
|
||||
Err("the anonymous sasl mechanism requires no credentials".to_owned())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue