mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
isolate scram behind a compilation feature
This commit is contained in:
parent
47bc133c44
commit
50bf8cf60a
6 changed files with 24 additions and 1 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::{Identity, Credentials};
|
||||
|
||||
#[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>;
|
||||
}
|
||||
|
||||
|
@ -55,6 +59,7 @@ pub mod mechanisms {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "scram")]
|
||||
mod scram {
|
||||
use std::marker::PhantomData;
|
||||
|
||||
|
@ -215,5 +220,6 @@ pub mod mechanisms {
|
|||
}
|
||||
|
||||
pub use self::plain::Plain;
|
||||
#[cfg(feature = "scram")]
|
||||
pub use self::scram::Scram;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue