25 releases (14 breaking)

0.15.0 Mar 20, 2024
0.13.1 Jan 24, 2024
0.11.3 Dec 31, 2023
0.10.2 Nov 29, 2023
0.4.0 Nov 28, 2022

#49 in HTTP server

Download history 624/week @ 2023-12-07 771/week @ 2023-12-14 565/week @ 2023-12-21 633/week @ 2023-12-28 782/week @ 2024-01-04 813/week @ 2024-01-11 1054/week @ 2024-01-18 1128/week @ 2024-01-25 1071/week @ 2024-02-01 2116/week @ 2024-02-08 1459/week @ 2024-02-15 1674/week @ 2024-02-22 1897/week @ 2024-02-29 1710/week @ 2024-03-07 1746/week @ 2024-03-14 2444/week @ 2024-03-21

8,033 downloads per month
Used in 2 crates

MIT license

61KB
1K 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.

If 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.15.0"

🤸 Usage

We recommend reviewing our sqlite example.

[!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

~13–24MB
~416K SLoC