Skip to main content

Configuration

The SDK is configured through two structs: AppConfig (HTTP / route-level concerns) and AuthServiceConfig (JWT / cryptographic concerns). Both are plain Rust structs — populate them however you like (env vars, TOML, JSON, hardcoded).

AppConfig

use identsphere_axum::AppConfig;

let cfg = AppConfig {
app_name: "Acme".into(),
public_base_url: "https://auth.example.com".into(),
from_email: "no-reply@example.com".into(),
cookies_secure: true,
route_prefix: "/v1/auth".into(),
refresh_cookie_max_age_secs: 30 * 24 * 60 * 60,
step_up_ttl_secs: 30 * 60,
rp_id: "auth.example.com".into(),
rp_origin: "https://auth.example.com".into(),
rp_name: "Acme".into(),
oauth_google_client_id: Some("...".into()),
oauth_google_client_secret: Some("...".into()),
oauth_github_client_id: Some("...".into()),
oauth_github_client_secret: Some("...".into()),
..Default::default()
};
FieldDefaultNotes
app_name"IdentSphere"Shown in email subjects, TOTP issuer.
public_base_urlhttp://localhost:3000Canonical URL of the host. Used to build links in transactional emails.
from_emailno-reply@example.comSender of transactional emails. Must be a verified address on your sending domain.
cookies_securefalseMust be true in production. Toggles the Secure cookie attribute.
route_prefix/v1/authPath the SDK is mounted under. Scopes the refresh-token cookie.
refresh_cookie_max_age_secs2592000 (30d)Refresh-cookie lifetime.
step_up_ttl_secs1800 (30 min)How long a step-up MFA assertion remains valid.
rp_idlocalhostWebAuthn Relying Party ID. Host of public_base_url, no scheme or port.
rp_originhttp://localhost:3000WebAuthn origin: full URL with scheme.
rp_nameIdentSphereUser-facing RP name.
oauth_google_client_id / _secretNoneOptional. If unset, the Google /start endpoint returns 404.
oauth_github_client_id / _secretNoneSame.

::: warning cookies_secure in production cookies_secure = false in production means the session cookie is sent over plaintext HTTP. Don't ship that. :::

AuthServiceConfig

use identsphere_core::services::AuthServiceConfig;

let auth_cfg = AuthServiceConfig {
jwt_secret: std::env::var("IDENTSPHERE_JWT_SECRET").expect("set JWT secret"),
issuer: "IdentSphere".into(),
access_expiry_secs: 900, // 15 min
refresh_expiry_secs: 30 * 24 * 60 * 60, // 30 days
..Default::default()
};
FieldDefaultNotes
jwt_secret(empty)Required. HS256 signing key. Minimum 32 bytes from a CSPRNG.
issuer"IdentSphere"iss claim on every minted JWT.
access_expiry_secs900Access-token TTL.
refresh_expiry_secs2592000Refresh-token TTL. Should be ≥ refresh_cookie_max_age_secs.

::: warning Rotating jwt_secret Rotating the JWT secret invalidates every outstanding session. There is no second-key grace window in v0.1. Plan for forced sign-out when you rotate. :::

Providers (traits)

The SDK ships defaults you can override:

use std::sync::Arc;
use identsphere_core::providers::email::LogOnlySender;
use identsphere_core::providers::storage::LocalFsStorage;
use identsphere_core::providers::cache::PostgresOnlyCache;

let state = AppState {
config: Arc::new(cfg),
db: db.clone(),
auth_service: Arc::new(auth_service),
session_cache: Arc::new(PostgresOnlyCache::new(db.clone())),
email_sender: Arc::new(LogOnlySender),
object_storage: Arc::new(
LocalFsStorage::new("./uploads", "http://localhost:4000/files")
),
// ...
};
TraitDefaultProduction options
EmailSenderLogOnlySender (prints to stdout)SMTP, Resend, SES, SendGrid — bring your own
ObjectStorageLocalFsStorageS3Storage (S3, R2, MinIO), GcsStorage (GCS)
SessionCachePostgresOnlyCacheRedisCache

Implementing your own is one trait impl each — see the trait docs in identsphere_core::providers.

Putting it together

use axum::Router;
use identsphere_axum::{routes, AppState};
use std::sync::Arc;

let app = Router::new()
.nest("/v1/auth", routes::auth::router())
.nest("/v1/auth/mfa", routes::mfa::router())
.nest("/v1/users/me", routes::users::router())
// ...
.with_state(state);

The full wiring is in Quick start.

See also