https://github.com/maxcountryman/axum-login
🪪 User identification, authentication, and authorization for Axum.
https://github.com/maxcountryman/axum-login
access-control authentication authorization axum login
Last synced: about 1 year ago
JSON representation
🪪 User identification, authentication, and authorization for Axum.
- Host: GitHub
- URL: https://github.com/maxcountryman/axum-login
- Owner: maxcountryman
- License: mit
- Created: 2022-08-27T17:13:06.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-15T23:32:25.000Z (over 1 year ago)
- Last Synced: 2025-05-11T17:46:24.634Z (about 1 year ago)
- Topics: access-control, authentication, authorization, axum, login
- Language: Rust
- Homepage:
- Size: 251 KB
- Stars: 783
- Watchers: 7
- Forks: 80
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
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`](https://github.com/maxcountryman/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:
```toml
[dependencies]
axum-login = "0.17.0"
```
## 🤸 Usage
We recommend reviewing our [`sqlite` example][sqlite-example]. There is also a [template for `cargo-generate` using postgres](https://gitlab.com/maxhambraeus/axum-login-postgres-template).
> [!NOTE]
> See the [crate documentation][docs] 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][examples] to help get you started. You're also welcome to [open a discussion](https://github.com/maxcountryman/axum-login/discussions/new?category=q-a) and ask additional questions you might have.
## 👯 Contributing
We appreciate all kinds of contributions, thank you!
[sqlite-example]: https://github.com/maxcountryman/axum-login/tree/main/examples/sqlite
[examples]: https://github.com/maxcountryman/axum-login/tree/main/examples
[docs]: https://docs.rs/axum-login