FastAuth¶
fastauth.app.FastAuth
¶
Central FastAuth instance wires configuration, providers, and adapters together.
Pass a :class:~fastauth.config.FastAuthConfig to the constructor, then call
:meth:mount to attach all authentication routes to a FastAPI application.
Example
from fastauth import FastAuth, FastAuthConfig
from fastauth.providers.credentials import CredentialsProvider
from fastauth.adapters.sqlalchemy import SQLAlchemyAdapter
adapter = SQLAlchemyAdapter(engine_url="sqlite+aiosqlite:///./auth.db")
config = FastAuthConfig(
secret="change-me-in-production",
providers=[CredentialsProvider()],
adapter=adapter.user,
token_adapter=adapter.token,
)
auth = FastAuth(config)
__init__
¶
Initialize FastAuth with the given configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FastAuthConfig
|
A fully-populated :class: |
required |
mount
¶
Mount all FastAuth routes onto a FastAPI application.
Attaches the authentication router at config.route_prefix (default
/auth). Also mounts the /.well-known/jwks.json endpoint when a
JWKS manager has been initialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
object
|
A :class: |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If app is not a :class: |
MissingDependencyError
|
If the |
initialize_roles
async
¶
initialize_jwks
async
¶
Initialize the JWKS manager for RSA-based JWT signing.
Must be called inside the application lifespan startup handler when using
RS256 / RS512 algorithms with jwks_enabled=True.