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:

  1. Who is calling? An identity, a user or an API key, proven by the Authorization header.
  2. What may they do? Decided by the policies attached to the caller, and for users also by bucket rules.

Three kinds of callers

IdentityUserAPI key
CredentialIdentifier and password, or SAMLUsername and password, OTP, magic link or OAuthA static key
HeaderAuthorization: IDENTITY <jwt>Authorization: USER <jwt>Authorization: APIKEY <key>
ExpiresYes, refreshableYes, refreshableNo, until deactivated or deleted
Bucket rules appliedNoYesNo
Two-factor authenticationTOTPTOTPNo

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
  → handler

Policies are evaluated on every request, so changes to policies take effect immediately, even for tokens that were issued earlier.

In this section

PageCovers
IdentitiesCreating team accounts, the default identity, logging in.
UsersSign-up, login, verification, password reset, passwordless login, bans.
Tokens & sessionsJWT lifetimes, refresh tokens, verifying and revoking tokens.
API keysCreating keys, attaching policies, rotating keys.
PoliciesStatements, actions, resources and the built-in policies.
StrategiesSAML for identities, OAuth providers for users.
Two-factor authenticationTOTP setup and login challenges.
Password & login securityPassword policies, history, lockout and rate limits.