2018-05-30 16:43:39 +03:00
|
|
|
use super::AuthenticationError;
|
2019-05-15 17:38:55 +03:00
|
|
|
use crate::headers::www_authenticate::Challenge;
|
2018-05-30 16:43:39 +03:00
|
|
|
|
2019-05-17 17:28:57 +03:00
|
|
|
/// Trait implemented for types that provides configuration
|
|
|
|
/// for the authentication [extractors].
|
|
|
|
///
|
|
|
|
/// [extractors]: ./trait.AuthExtractor.html
|
|
|
|
pub trait AuthExtractorConfig {
|
|
|
|
/// Associated challenge type.
|
2018-05-30 16:43:39 +03:00
|
|
|
type Inner: Challenge;
|
|
|
|
|
2019-05-17 17:28:57 +03:00
|
|
|
/// Convert the config instance into a HTTP challenge.
|
2018-05-30 16:43:39 +03:00
|
|
|
fn into_inner(self) -> Self::Inner;
|
|
|
|
}
|
|
|
|
|
2019-05-17 17:28:57 +03:00
|
|
|
impl<T> From<T> for AuthenticationError<<T as AuthExtractorConfig>::Inner>
|
2019-05-15 17:38:55 +03:00
|
|
|
where
|
2019-05-17 17:28:57 +03:00
|
|
|
T: AuthExtractorConfig,
|
2019-05-15 17:38:55 +03:00
|
|
|
{
|
2018-05-30 16:43:39 +03:00
|
|
|
fn from(config: T) -> Self {
|
|
|
|
AuthenticationError::new(config.into_inner())
|
|
|
|
}
|
|
|
|
}
|