Features
A complete map of what AllSafe Fast provides today, what's in progress, and what's planned. Every feature listed as Implemented is available in the current release. Features marked Planned are on the roadmap but not yet shipped.
Authentication Providers
AllSafe Fast ships five authentication providers. Each implements the AuthProvider protocol and can be enabled independently. You can also build your own — the provider interface is fully public.
| Provider | Description | Status |
|---|---|---|
| Password | Email + password sign-up and sign-in. Argon2id hashing, email verification, password reset. | Implemented |
| OAuth 2.0 | Authorization Code flow with PKCE. Supports Google, GitHub, GitLab, and any OAuth 2.0 provider. | Implemented |
| OIDC | OpenID Connect with JWKS discovery and ID token verification. Supports any OIDC-compliant provider. | Implemented |
| Magic Link | Passwordless sign-in via a one-time link sent to the user's email. 15-minute expiry, single use. | Implemented |
| Email OTP | Passwordless sign-in via a 6-digit one-time code sent to the user's email. 15-minute expiry, 3 attempts max. | Implemented |
Every provider implements authenticate(context), get_identity(result), and contributes its own routes and Pydantic schemas. The ProviderRegistry manages registration and lookup by ID. Adding a provider never touches core logic.
Session Management
Sessions are the bridge between authentication (one-time proof of identity) and ongoing access (remembering the user across requests). AllSafe Fast uses a hybrid JWT + refresh token model.
| Feature | Description | Status |
|---|---|---|
| JWT Access Tokens | Short-lived (15 min) signed JWTs containing user ID, email, verification status, roles, and permissions. Verified in memory — no database query on every request. | Implemented |
| Refresh Token Rotation | Long-lived (30 day) refresh tokens. Each use issues a new token and revokes the old one. Stored as SHA-256 hashes — the raw token is returned once and never persisted. | Implemented |
| Theft Detection | If a revoked refresh token is presented again, all of the user's sessions are immediately revoked and a TokenReuseError is raised. | Implemented |
| Session Revocation | Revoke a single session or all sessions for a user. Used by password reset, sign-out, and theft detection. | Implemented |
| Session Listing | List all active sessions for a user, including IP address and user agent from sign-in time. | Implemented |
| Session Management UI | A prebuilt dashboard for users to view and revoke their own sessions. | Planned |
Authorization
Authorization is enforced at the dependency level — the same dependency that authenticates also checks roles and permissions. Checks are stateless and in-memory because roles and permissions are embedded in the JWT.
| Feature | Description | Status |
|---|---|---|
| Roles | Assign roles to users (e.g. admin, moderator). Require a single role with auth.user(role="admin") or any of several with auth.user(roles=["admin", "editor"]). | Implemented |
| Permissions | Assign fine-grained permissions (e.g. reports:export, users:delete). Require one with auth.user(permission="...") or all of a set with auth.user(permissions=[...]). | Implemented |
| Email Verification Gate | Require a verified email with auth.user(verified=True). Useful for sensitive operations. | Implemented |
| Route Protection | One dependency — auth.user() — handles authentication, verification, role checks, and permission checks. No separate middleware or decorators. | Implemented |
# Authorization is a keyword argument, not a separate system
@app.get("/admin")
async def admin(user=auth.user(role="admin")):
...
@app.delete("/users/{id}")
async def delete_user(id: str, user=auth.user(permission="users:delete")):
...
@app.post("/transfer")
async def transfer(user=auth.user(verified=True, permissions=["funds:send", "funds:receive"])):
...
Security
Security is not a feature you add later — it's the foundation. AllSafe Fast defaults to the safest option at every decision point and refuses to start in production with an insecure configuration.
| Feature | Description | Status |
|---|---|---|
| Argon2id Password Hashing | OWASP-recommended memory-hard algorithm. Auto-generated salts, configurable time/memory/parallelism parameters. | Implemented |
| CSRF Protection | Cookie-based auth requires the X-AllSafe-CSRF header on every state-changing request. Bearer-token auth is immune by design. | Implemented |
| Rate Limiting | Sliding-window rate limiter for auth endpoints. Redis backend for production, in-memory for development. | Implemented |
| Enumeration Prevention | Login, sign-up, and password-reset return generic messages that don't reveal whether an email is registered. | Implemented |
| Production Guards | Refuses to start in production with a default secret key, insecure cookies, or an insecure configuration. | Implemented |
| Secure Cookies | HttpOnly + Secure + SameSite=Lax by default. Configurable per environment. | Implemented |
| Token Hashing | Refresh and verification tokens are SHA-256 hashed before storage. Raw tokens are returned once and never persisted. | Implemented |
| Constant-Time Comparison | Token verification uses hmac.compare_digest to prevent timing attacks. | Implemented |
Extensibility
AllSafe Fast is designed to be extended, not forked. Hooks, plugins, custom providers, and protocol-based storage let you add behavior without modifying the framework.
| Feature | Description | Status |
|---|---|---|
| Plugins | Implement the AllSafePlugin protocol to contribute routes, database tables, hooks, and schemas. Wired automatically by the PluginRegistry. | Implemented |
| Hooks | 14 lifecycle events: user create, sign-in, session create/revoke, password reset, email verify, account link. Register via decorator, dict, or register_many. | Implemented |
| Custom Providers | Implement the AuthProvider protocol to add SAML, WebAuthn, or any custom authentication method. | Implemented |
| Storage Protocols | Four typing.Protocol interfaces. Implement your own adapter for MongoDB, DynamoDB, or any backend. | Implemented |
| Custom Email Service | Swap the default ConsoleEmailService for any implementation that sends transactional email. | Implemented |
14 Hook Events
Run custom logic on user creation, sign-in, session lifecycle, password reset, email verification, and account linking. Handlers fire synchronously in registration order and never break the auth flow.
Plugin System
Plugins contribute routes, tables, hooks, and schemas. The PluginContext gives them access to config, storage, JWT service, session manager, and the hook registry.
Custom Providers
The AuthProvider protocol is fully public. Implement authenticate() and get_identity(), contribute your routes and schemas, and register with the ProviderRegistry.
CLI Tools
The allsafe command-line interface scaffolds projects, generates secrets, manages migrations, and diagnoses configuration issues.
| Command | Description | Status |
|---|---|---|
allsafe init | Scaffold a new project: create .env, generate a secret key, and create a starter configuration. | Implemented |
allsafe secret | Generate a cryptographically secure secret key for JWT signing. | Implemented |
allsafe db generate | Generate SQLAlchemy migration scripts from the AllSafe Fast schema. | Implemented |
allsafe db migrate | Apply pending migrations to the database. | Implemented |
allsafe doctor | Diagnose your configuration and report security issues, missing dependencies, and environment problems. | Implemented |
Storage
The core logic depends on storage protocols, not concrete implementations. Two backends ship; you can write your own.
| Backend | Description | Status |
|---|---|---|
| In-Memory | Default for development and testing. asyncio.Lock-guarded. Lost on restart. | Implemented |
| Async SQLAlchemy | Production backend. PostgreSQL with native UUID and ARRAY types, async asyncpg driver, cascade deletes, indexed lookups. | Implemented |
| Redis | For distributed rate limiting and session storage. | Planned |
| MongoDB | NoSQL adapter implementing the four storage protocols. | Planned |
The four storage protocols — UserStoreProtocol, AccountStoreProtocol, SessionStoreProtocol, VerificationStoreProtocol — are typing.Protocol interfaces. The StorageAdapter bundles all four. Swap in-memory for SQLAlchemy (or your own adapter) by changing one constructor argument. Core services never import SQLAlchemy.
Feature Summary
5 Auth Providers
Password, OAuth 2.0, OIDC, Magic Link, Email OTP — all implemented and configurable.
JWT + Refresh
Access tokens in memory, refresh tokens in the database with rotation and theft detection.
8 Security Features
Argon2id, CSRF, rate limiting, enumeration prevention, production guards, secure cookies, token hashing, constant-time comparison.
2 Storage Backends
In-memory for dev, async SQLAlchemy for production. Protocol-based for custom backends.
14 Hooks
Lifecycle events for user, session, password, email, and account operations.
5 CLI Commands
init, secret, db generate, db migrate, doctor.