Rust library for HTTP authentication. Parses challenge lists, responds
to Basic
and Digest
challenges. Likely to be extended with server
support and additional auth schemes.
HTTP authentication is described in the following documents and specifications:
This framework is primarily used with HTTP, as suggested by the name. It is also used by some other protocols such as RTSP.
Young but well-tested. The API may change to improve ergonomics and functionality. New functionality is likely to be added. PRs welcome!
In order:
unsafe
blocks in http-auth
itself. All
dependencies are common, trusted crates.http_auth::DigestClient
currently weighs
in at 40 bytes plus one allocation for all string fields.Basic
and Digest
schemes; future expansion is likely.)http::header::GetAll
].http-auth
's CPU usage should never be noticeable. For Digest
's
cryptographic operations, it uses popular optimized crates. In other
respects, http-auth
is likely at least as efficient as other HTTP
authentication crates, although I have no reason to believe their
performance is problematic.There are at least a couple other available crates relating to HTTP
authentication. You may prefer them. Here's why http-auth
's author decided
not to use them.
www-authenticate
www-authenticate
has some unsound transmute
s to static lifetime.
(These likely aren't hard to fix though.)www-authenticate
depends on hyperx
and unicase
, large
dependencies which many useful programs don't include.www-authenticate
only supports parsing of challenge lists, not
responding to them.digest_auth
digest_auth
only supports Digest
. It can't parse multiple
challenges and will fail if given a list that starts with another scheme.
Thus, if the server follows the advice of
RFC 7235 section 2.1 and
lists another scheme such as Basic
first, digest_auth
's parsing is
insufficient.www-authenticate
+ digest_auth
togetherIn addition to the www-authenticate
caveats above, responding to password
challenges by using both www-authenticate
and digest_auth
is not complete
and ergonomic. The caller must do extra work:
Digest
and Basic
, rather than using the
abstract http_auth::PasswordClient
that chooses the challenge for you.Digest
challenge, construct a matching
digest_auth::WwwAuthenticateHeader
from the
www_authenticate::DigestChallenge
.Basic
challenge, do the encoding manually.Scott Lamb <slamb@slamb.org>
SPDX-License-Identifier: MIT OR Apache-2.0
See LICENSE-MIT.txt or LICENSE-APACHE, respectively.