Built around Axum and Postgres with custom sessions, email/password flows, OAuth, and a CLI for migrations.
rs-auth is an authentication library for Rust. It provides email/password auth, database-backed sessions, email verification, password reset, and OAuth — all designed for Axum and PostgreSQL.
[dependencies]
rs-auth = "0.1"Built-in credential auth.
Signup, login, logout with secure password hashing, email verification, and password reset.
Database-backed sessions.
Opaque tokens stored in Postgres with signed cookies and configurable expiry.
Framework-native.
Router, extractors, middleware, and a prebuilt auth handler you nest into your app.
Social sign-on.
Google and GitHub flows with automatic account linking and state verification.
SQLx-backed storage.
Migrations, session tracking, user management, and OAuth account persistence.
Developer tooling.
Run migrations, manage configuration, and scaffold auth setup from the command line.
use axum::Router;
use rs_auth::axum::{auth_router, AuthState};
use rs_auth::config::AuthConfig;
let config = AuthConfig::builder()
.database_url(env::var("DATABASE_URL")?)
.cookie_secret(env::var("COOKIE_SECRET")?)
.build();
let state = AuthState::new(config).await?;
let auth = auth_router(state.clone());
let app = Router::new()
.nest("/auth", auth)
.with_state(state);
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000")
.await?;
axum::serve(listener, app).await?;rs-auth is a Cargo workspace split into focused crates. Use only what you need, or pull in the facade crate for everything.
rs-authFacade crate that re-exports everything.
rs-auth-coreAuth logic, password hashing, token generation.
rs-auth-postgresSQLx-backed user, session, and OAuth storage.
rs-auth-axumAxum router, extractors, and middleware.
Get started
Read the docs, install the crate, and ship auth in minutes.