Authentication & access
How Spica authenticates identities, users and API keys, and how policies and rules decide what each of them may do.
Spica's authentication and authorization module is called Passport. It answers two questions for every request:
- Who is calling? An identity, a user or an API key, proven by the
Authorizationheader. - What may they do? Decided by the policies attached to the caller, and for users also by bucket rules.
Three kinds of callers
IdentitiesUsersAPI keys
Your team: developers, editors and operators who use the panel and the management APIs.
Your product's end users, with sign-up, verification, password reset and passwordless login.
Servers, functions, scripts, CI pipelines and the CLI.
| Identity | User | API key | |
|---|---|---|---|
| Credential | Identifier and password, or SAML | Username and password, OTP, magic link or OAuth | A static key |
| Header | Authorization: IDENTITY <jwt> | Authorization: USER <jwt> | Authorization: APIKEY <key> |
| Expires | Yes, refreshable | Yes, refreshable | No, until deactivated or deleted |
| Bucket rules applied | No | Yes | No |
| Two-factor authentication | TOTP | TOTP | No |
The request lifecycle
Text
Authorization header
→ authenticate: verify the token or key 401 when it fails
→ authorize: policies allow the action on the resource 403 when they don't
→ rules: for USER requests on bucket data, filter or reject documents
→ handlerPolicies are evaluated on every request, so changes to policies take effect immediately, even for tokens that were issued earlier.
In this section
| Page | Covers |
|---|---|
| Identities | Creating team accounts, the default identity, logging in. |
| Users | Sign-up, login, verification, password reset, passwordless login, bans. |
| Tokens & sessions | JWT lifetimes, refresh tokens, verifying and revoking tokens. |
| API keys | Creating keys, attaching policies, rotating keys. |
| Policies | Statements, actions, resources and the built-in policies. |
| Strategies | SAML for identities, OAuth providers for users. |
| Two-factor authentication | TOTP setup and login challenges. |
| Password & login security | Password policies, history, lockout and rate limits. |