Expand description
Basic authentication for trillium.rs
use trillium_basic_auth::BasicAuth;
trillium_smol::run((
BasicAuth::new("trillium", "7r1ll1um").with_realm("rust"),
|conn: trillium::Conn| async move { conn.ok("authenticated") },
));Requests that do not carry acceptable credentials are halted with a 401 Unauthorized and a
WWW-Authenticate challenge, so handlers placed after BasicAuth only run for
authenticated requests. The authenticated username is available downstream through
BasicAuthConnExt::basic_auth_username.
Credentials can be checked against a single configured username and password
(BasicAuth::new) or against a predicate of your own (BasicAuth::validate_fn,
BasicAuth::validate_async_fn).
Because HTTP Basic transmits the password in a reversible encoding on every request, it is only as confidential as the transport underneath it. Use it over https.
Structs§
- Basic
Auth - basic auth handler
- Credentials
- basic auth username-password credentials
Traits§
- Basic
Auth Conn Ext - extension trait for reading the authenticated username