pub struct BasicAuthHoop { /* private fields */ }Expand description
Basic authentication middleware.
Checks the Authorization: Basic <base64> header against a list of
configured users. Passwords may be stored as:
- Plaintext (if the hash does not start with a known prefix)
- Bcrypt hashes (starting with
$2b$,$2a$, or$2y$) - Argon2 hashes (starting with
$argon2id$or$argon2i$; requiresargon2feature) - Scrypt hashes (starting with
$scrypt$; requiresscryptfeature) - PBKDF2 hashes (starting with
$pbkdf2-sha256$; requirespbkdf2feature)
Returns 401 Unauthorized with a WWW-Authenticate challenge if
authentication fails.
Optionally enforces IP-based brute-force protection: after
brute_force_max consecutive failures the client IP is blocked for
brute_force_window. Returns 429 Too Many Requests when blocked.
Implementations§
Source§impl BasicAuthHoop
impl BasicAuthHoop
Trait Implementations§
Source§impl Handler for BasicAuthHoop
impl Handler for BasicAuthHoop
Source§fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Handle http request.
Source§fn arc(self) -> ArcHandlerwhere
Self: Sized,
fn arc(self) -> ArcHandlerwhere
Self: Sized,
Wrap to
ArcHandler.Source§fn hoop<H>(self, hoop: H) -> HoopedHandler
fn hoop<H>(self, hoop: H) -> HoopedHandler
Hoop this handler with middleware.
Auto Trait Implementations§
impl Freeze for BasicAuthHoop
impl !RefUnwindSafe for BasicAuthHoop
impl Send for BasicAuthHoop
impl Sync for BasicAuthHoop
impl Unpin for BasicAuthHoop
impl UnsafeUnpin for BasicAuthHoop
impl !UnwindSafe for BasicAuthHoop
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more