30 releases (16 breaking)

0.17.0 Jan 5, 2025
0.16.0 Sep 4, 2024
0.15.3 Jun 10, 2024
0.15.0 Mar 20, 2024
0.4.0 Nov 28, 2022

#38 in HTTP server

Download history 2896/week @ 2024-10-01 2451/week @ 2024-10-08 2478/week @ 2024-10-15 2857/week @ 2024-10-22 2604/week @ 2024-10-29 2758/week @ 2024-11-05 2290/week @ 2024-11-12 2710/week @ 2024-11-19 1972/week @ 2024-11-26 2723/week @ 2024-12-03 2993/week @ 2024-12-10 3211/week @ 2024-12-17 1282/week @ 2024-12-24 3552/week @ 2024-12-31 3894/week @ 2025-01-07 2818/week @ 2025-01-14

11,836 downloads per month
Used in 4 crates

MIT license

78KB
1.5K SLoC

axum-login

🪪 User identification, authentication, and authorization for Axum.

🎨 Overview

This crate provides user identification, authentication, and authorization as a tower middleware for axum.

It offers:

  • User Identification, Authentication, and Authorization: Leverage AuthSession to easily manage authentication and authorization. This is also an extractor, so it can be used directly in your axum handlers.
  • Support for Arbitrary Users and Backends: Applications implement a couple of traits, AuthUser and AuthnBackend, allowing for any user type and any user management backend. Your database? Yep. LDAP? Sure. An auth provider? You bet.
  • User and Group Permissions: Authorization is supported via the AuthzBackend trait, which allows applications to define custom permissions. Both user and group permissions are supported.
  • Convenient Route Protection: Middleware for protecting access to routes are provided via the login_required and permission_required macros. Or bring your own by using AuthSession directly with from_fn.
  • Rock-solid Session Management: Uses tower-sessions for high-performing and ergonomic session management. Look ma, no deadlocks!

📦 Install

To use the crate in your project, add the following to your Cargo.toml file:

[dependencies]
axum-login = "0.17.0"

🤸 Usage

We recommend reviewing our sqlite example. There is also a template for cargo-generate using postgres.

[!NOTE] See the crate documentation for usage information.

🦺 Safety

This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.

🛟 Getting Help

We've put together a number of examples to help get you started. You're also welcome to open a discussion and ask additional questions you might have.

👯 Contributing

We appreciate all kinds of contributions, thank you!

Dependencies

~7–16MB
~178K SLoC