Merge branch 'master' into 'master'
isolate scram behind a compilation feature See merge request !1
This commit is contained in:
commit
9edeaece21
6 changed files with 25 additions and 2 deletions
|
@ -13,6 +13,13 @@ license = "LGPL-3.0+"
|
|||
[badges]
|
||||
gitlab = { repository = "lumi/sasl-rs" }
|
||||
|
||||
[features]
|
||||
default = ["scram"]
|
||||
scram = ["openssl"]
|
||||
|
||||
[dependencies]
|
||||
openssl = "0.9.7"
|
||||
base64 = "0.4.0"
|
||||
|
||||
[dependencies.openssl]
|
||||
version = "0.9.7"
|
||||
optional = true
|
||||
|
|
|
@ -2,8 +2,12 @@
|
|||
|
||||
mod anonymous;
|
||||
mod plain;
|
||||
|
||||
#[cfg(feature = "scram")]
|
||||
mod scram;
|
||||
|
||||
pub use self::anonymous::Anonymous;
|
||||
pub use self::plain::Plain;
|
||||
|
||||
#[cfg(feature = "scram")]
|
||||
pub use self::scram::Scram;
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::convert::From;
|
|||
|
||||
use std::string::FromUtf8Error;
|
||||
|
||||
#[cfg(feature = "scram")]
|
||||
pub mod scram;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
#[cfg(feature = "scram")]
|
||||
use openssl::error::ErrorStack;
|
||||
|
||||
/// A wrapper enum for things that could go wrong in this crate.
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
#[cfg(feature = "scram")]
|
||||
/// An error in OpenSSL.
|
||||
OpenSslErrorStack(ErrorStack),
|
||||
/// An error in a SASL mechanism.
|
||||
SaslError(String),
|
||||
}
|
||||
|
||||
#[cfg(feature = "scram")]
|
||||
impl From<ErrorStack> for Error {
|
||||
fn from(err: ErrorStack) -> Error {
|
||||
Error::OpenSslErrorStack(err)
|
||||
|
|
|
@ -124,6 +124,8 @@
|
|||
//! ```
|
||||
|
||||
extern crate base64;
|
||||
|
||||
#[cfg(feature = "scram")]
|
||||
extern crate openssl;
|
||||
|
||||
mod error;
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
use common::scram::ScramProvider;
|
||||
use common::{Credentials, Identity};
|
||||
|
||||
#[cfg(feature = "scram")]
|
||||
use common::scram::ScramProvider;
|
||||
|
||||
pub trait Validator {
|
||||
fn validate_credentials(&self, credentials: &Credentials) -> Result<Identity, String>;
|
||||
|
||||
#[cfg(feature = "scram")]
|
||||
fn request_pbkdf2<S: ScramProvider>(&self) -> Result<(Vec<u8>, usize, Vec<u8>), String>;
|
||||
}
|
||||
|
||||
|
@ -63,6 +67,7 @@ pub mod mechanisms {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "scram")]
|
||||
mod scram {
|
||||
use std::marker::PhantomData;
|
||||
|
||||
|
@ -235,5 +240,6 @@ pub mod mechanisms {
|
|||
}
|
||||
|
||||
pub use self::plain::Plain;
|
||||
#[cfg(feature = "scram")]
|
||||
pub use self::scram::Scram;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue