Merge branch 'master' into 'master'

isolate scram behind a compilation feature

See merge request !1
This commit is contained in:
lumi 2017-03-25 14:06:25 +00:00
commit 4538629a42
6 changed files with 24 additions and 1 deletions

View file

@ -13,6 +13,13 @@ license = "LGPL-3.0+"
[badges] [badges]
gitlab = { repository = "lumi/sasl-rs" } gitlab = { repository = "lumi/sasl-rs" }
[features]
default = ["scram"]
scram = ["openssl"]
[dependencies] [dependencies]
openssl = "0.9.7"
base64 = "0.4.0" base64 = "0.4.0"
[dependencies.openssl]
version = "0.9.7"
optional = true

View file

@ -2,8 +2,12 @@
mod anonymous; mod anonymous;
mod plain; mod plain;
#[cfg(feature = "scram")]
mod scram; mod scram;
pub use self::anonymous::Anonymous; pub use self::anonymous::Anonymous;
pub use self::plain::Plain; pub use self::plain::Plain;
#[cfg(feature = "scram")]
pub use self::scram::Scram; pub use self::scram::Scram;

View file

@ -4,6 +4,7 @@ use std::convert::From;
use std::string::FromUtf8Error; use std::string::FromUtf8Error;
#[cfg(feature = "scram")]
pub mod scram; pub mod scram;
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]

View file

@ -1,14 +1,17 @@
#[cfg(feature = "scram")]
use openssl::error::ErrorStack; use openssl::error::ErrorStack;
/// A wrapper enum for things that could go wrong in this crate. /// A wrapper enum for things that could go wrong in this crate.
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
#[cfg(feature = "scram")]
/// An error in OpenSSL. /// An error in OpenSSL.
OpenSslErrorStack(ErrorStack), OpenSslErrorStack(ErrorStack),
/// An error in a SASL mechanism. /// An error in a SASL mechanism.
SaslError(String), SaslError(String),
} }
#[cfg(feature = "scram")]
impl From<ErrorStack> for Error { impl From<ErrorStack> for Error {
fn from(err: ErrorStack) -> Error { fn from(err: ErrorStack) -> Error {
Error::OpenSslErrorStack(err) Error::OpenSslErrorStack(err)

View file

@ -124,6 +124,8 @@
//! ``` //! ```
extern crate base64; extern crate base64;
#[cfg(feature = "scram")]
extern crate openssl; extern crate openssl;
mod error; mod error;

View file

@ -1,8 +1,12 @@
use common::{Identity, Credentials}; use common::{Identity, Credentials};
#[cfg(feature = "scram")]
use common::scram::ScramProvider; use common::scram::ScramProvider;
pub trait Validator { pub trait Validator {
fn validate_credentials(&self, credentials: &Credentials) -> Result<Identity, String>; 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>; fn request_pbkdf2<S: ScramProvider>(&self) -> Result<(Vec<u8>, usize, Vec<u8>), String>;
} }
@ -55,6 +59,7 @@ pub mod mechanisms {
} }
} }
#[cfg(feature = "scram")]
mod scram { mod scram {
use std::marker::PhantomData; use std::marker::PhantomData;
@ -215,5 +220,6 @@ pub mod mechanisms {
} }
pub use self::plain::Plain; pub use self::plain::Plain;
#[cfg(feature = "scram")]
pub use self::scram::Scram; pub use self::scram::Scram;
} }