RustAuth is an unofficial Rust authentication toolkit inspired by Better Auth.
It is server-first: sessions, OAuth/OIDC, SSO, SCIM, SAML, passkeys, plugins, storage adapters,
and Axum and Actix Web integrations live in the rustauth-* crates.
0.3.0 adds Actix Web integration, Diesel storage adapters, and CLI breaking changes. The API is pre-1.0; breaking changes are still possible before 1.0.
use rustauth::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let auth = RustAuth::builder()
.secret("secret-a-at-least-32-chars-long!!")
.base_url("https://app.example.com/api/auth")
.build()
.await?;
Ok(())
}Mount into Axum with rustauth-axum or Actix Web with rustauth-actix-web:
use rustauth_axum::RustAuthAxumExt;
let app = auth.mount_at_base_path(RustAuthAxumOptions::default())?;use rustauth_actix_web::RustAuthActixWebExt;
let scope = auth.mount_at_base_path(RustAuthActixWebOptions::default())?;Run rustauth init --framework axum or rustauth init --framework actix-web to create
rustauth.toml, keep [plugins].enabled in sync with the plugins
you register in Rust, then rustauth db migrate --yes before serving traffic. See
docs/database-migrations.md.
Start with the umbrella rustauth crate — its README links every
rustauth-* package (core, axum, actix-web, cli, plugins, OAuth, SSO, SCIM, adapters, and more).
SQLx (rustauth-sqlx) is the primary adapter family for SQLite, Postgres, and MySQL.
For apps that already use Diesel, rustauth-diesel
provides Postgres and MySQL adapters via diesel-async. Native Postgres pools are
also available through rustauth-tokio-postgres and rustauth-deadpool-postgres.
- Site: rustauth.dev
- Better Auth parity index:
docs/parity/README.md - Upstream pin:
reference/upstream-better-auth/VERSION.md
Source: salasebas/rustauth
cargo install --locked cargo-nextest
./scripts/ensure-test-services.sh postgres mysql redis valkey
cargo nextest run --workspace --all-features
cargo test --workspace --doc --all-featuresMIT — see LICENSE.