rustauth
Main application crate for RustAuth.
What It Is
rustauth is the crate most applications should start with. Use prelude
for the app-dev surface, then reach into focused modules (rustauth::db, rustauth::plugin,
rustauth::api, …) when you extend adapters, plugins, or endpoints.
Depend on rustauth-core directly only for adapter/plugin internals or very small binaries
that do not need the umbrella crate.
Quick Start
use *;
async
Attach an adapter when you need durable users, sessions, accounts, plugin data,
or migrations. Enable the matching SQLx dialect on the rustauth crate
(sqlx-sqlite, sqlx-postgres, or sqlx-mysql):
[]
= { = "0.1.0", = ["sqlx-sqlite"] }
= { = "1", = ["macros", "rt-multi-thread"] }
use *;
use SqliteAdapter;
use SqlitePoolOptions;
async
Configure rustauth.toml with the same adapter and plugins, then run
rustauth db migrate --yes in local setup, CI, or release jobs before starting
the server. See docs/database-migrations.md.
Mount into Axum with rustauth-axum:
use *;
use RustAuthAxumExt;
let app = auth.mount_at_base_path?;
Plugins
Enable the plugins feature to re-export rustauth-plugins, then register
official plugins on the builder:
use RustAuth;
use *;
let auth = builder
.secret
.plugin
.plugins
.build?;
# let _ = auth;
# Ok::
.plugin(x)appends one plugin..plugins(vec![...])appends a batch (like chaining.plugin).
When configuring RustAuthOptions
directly, .plugin and .plugins both append; use .set_plugins to replace
the entire plugin list.
Social Sign-In
Built-in OAuth providers live in rustauth-social-providers
and are re-exported as rustauth::social_providers. Register providers on the
builder:
use RustAuth;
use github;
use SocialProviderConfig;
let auth = builder
.secret
.base_url
.social_provider
.build?;
# let _ = auth;
# Ok::
Use SocialProviderConfig::builder() when credentials or scopes are loaded in
separate steps. Low-level provider types remain under
rustauth::social_providers::advanced.
Feature Flags
jose: forwardrustauth-core/jose(recommended for production cookie JWE).oauth: forwardrustauth-core/oauth(re-exportsrustauth::oauth).social-providers: forward social provider packages (requiresoauth).full: restore 0.1.x implicit behavior (jose+oauth+social-providers).plugins: re-exportrustauth-plugins(does not implyoauth; enableoauth/social-providersexplicitly when you need social sign-in).oauth-provider: re-exportrustauth-oauth-providerasrustauth::oauth_provider.passkey: re-exportrustauth-passkey.sso: re-exportrustauth-sso(includesrustauth::sso::oidcand, with thesamlfeature,rustauth::sso::saml).oidc: enable OIDC route support onrustauth-sso(does not add a top-levelrustauth::oidcre-export).samlandsaml-signed: enable SAML routes onrustauth-sso(does not add a top-levelrustauth::samlre-export).scim: re-export server-side SCIM provisioning.stripe: re-exportrustauth-stripeasrustauth::stripe(stripe,StripeOptions,StripeClient, …).i18n: re-exportrustauth-i18nasrustauth::i18n.telemetry: re-exportrustauth-telemetryunderrustauth::telemetry(create_telemetry,TelemetryContext,TelemetryEvent,TelemetryPublisher,CustomTrackFn, …) and wire the publisher duringRustAuthBuilder::build. This feature also enablesrustauth-telemetry/oauthso social-provider config snapshots match Better Auth parity.sqlx-sqlite,sqlx-postgres,sqlx-mysql: SQLx adapters.tokio-postgresanddeadpool-postgres: Postgres adapters.
Choosing The Right Crate
- Start with
rustauthfor applications. - Use
rustauth-corefor adapter/plugin internals. - Use
rustauth-ssoto consume external enterprise IdPs. - Enable
oauth-provideronrustauth(or depend onrustauth-oauth-providerdirectly) when your app must issue OAuth/OIDC tokens. - Use
rustauth-axumto mount RustAuth in Axum.
Enterprise plugins (quick start)
[]
= { = "0.2.0", = ["sso", "scim", "passkey", "oauth-provider"] }
use ;
use ;
use ;
use ;
use ;
let options = new
.secret
.base_url
.plugins;
let auth = builder.options.build?;
# let _ = auth;
# Ok::
Status
0.2.0 — initial public working release. Pre-1.0; public APIs may still change before 1.0.
Better Auth compatibility
Server-side public entry crate (builder, handler, re-exports). Aligned with Better Auth 1.6.9 where it matters for this crate; RustAuth is not a line-by-line port.
For route-level parity, test counts, intentional differences, and known gaps, see UPSTREAM.md.