$ show maxcountryman/axum-login
axum-login is a Rust library providing user identification, authentication, and authorization as tower middleware for Axum web applications. It enables pluggable authentication backends through well-designed traits (AuthUser, AuthnBackend, AuthzBackend) and offers flexible route protection via both macro-based and builder-based middleware APIs. The library uses tower-sessions for secure session management and includes features like session fixation mitigation and constant-time password verification. Examples demonstrate usage with various backends including SQLite, OAuth2, and permission-based systems.
The LLM identified 2 files worth highlighting for reuse:
Defines the core AuthUser, AuthnBackend, and AuthzBackend traits that form the foundation of the authentication system. These traits provide a clean, minimal interface for pluggable authentication backends (databases, LDAP, OAuth providers, etc.) and demonstrate excellent Rust trait design with associated types and proper trait bounds.
Implements the core RequireService that enforces authentication and authorization policies. Shows skilled use of the builder pattern with type-erased decision predicates and handlers, Arc-sharing for efficient state propagation, and proper integration with Tower's service model. The design allows flexible configuration of authentication logic while maintaining zero-cost abstractions where possible.