#basic-authentication #http #digest #basic #http-server #basic-auth

http-auth

HTTP authentication: parse challenge lists, respond to Basic and Digest challenges. Likely to be extended with server support and additional auth schemes.

10 releases

0.1.9 Dec 28, 2023
0.1.8 Jan 30, 2023
0.1.6 May 2, 2022
0.1.5 Nov 30, 2021
0.1.3 Oct 21, 2021

#32 in Authentication

Download history 17466/week @ 2023-12-23 22964/week @ 2023-12-30 26909/week @ 2024-01-06 23042/week @ 2024-01-13 24701/week @ 2024-01-20 26804/week @ 2024-01-27 31609/week @ 2024-02-03 32570/week @ 2024-02-10 34063/week @ 2024-02-17 37677/week @ 2024-02-24 42363/week @ 2024-03-02 44749/week @ 2024-03-09 47636/week @ 2024-03-16 42915/week @ 2024-03-23 39400/week @ 2024-03-30 31177/week @ 2024-04-06

168,538 downloads per month
Used in 106 crates (5 directly)

MIT/Apache

105KB
2K SLoC

crates.io Released API docs CI

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.

Status

Well-tested, suitable for production. The API may change to improve ergonomics and functionality. New functionality is likely to be added. PRs welcome!

Goals

In order:

  1. sound. Currently no unsafe blocks in http-auth itself. All dependencies are common, trusted crates.
  2. correct. Precisely implements the specifications except where noted. Fuzz tests verify the hand-written parser never panics and matches a nom-based reference implementation.
  3. light-weight. Minimal dependencies; uses Cargo features so callers can avoid them when undesired. Simple code that minimizes monomorphization bloat. Small data structures; eg http_auth::DigestClient currently weighs in at 32 bytes plus one allocation for all string fields.
  4. complete. Implements both parsing and responding to challenges. (Currently only supports the client side and responding to the most common Basic and Digest schemes; future expansion is likely.)
  5. ergonomic. Creating a client for responding to a password challenge is a one-liner from a string header or a http::header::GetAll.
  6. fast enough. HTTP authentication is a small part of a real program, and 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.

Author

Scott Lamb <slamb@slamb.org>

License

SPDX-License-Identifier: MIT OR Apache-2.0

See LICENSE-MIT.txt or LICENSE-APACHE, respectively.

Dependencies

~170–680KB
~11K SLoC