Skip to Content
Apso is in public beta. Get started
GuidesAuthOverview

Authentication

Authentication identifies the caller. Authorization decides which records and actions that caller can access. In an Apso service, the selected auth provider populates a normalized request context that generated tenant scoping and custom extensions can use.

Request lifecycleOne request, with every backend boundary visible.
Authenticated
  1. 01ClientServer component, mobile app, or service
  2. 02SDK or RESTTyped operation and validated payload
  3. 03IdentitySession, JWT, or API key context
  4. 04Tenant scopeAuthorization and row boundary
  5. 05ServiceGenerated route, product logic, and database
Keep privileged credentials on the server and pass only verified identity and tenant context into the generated service.

Choose a strategy

CallerStrategyProvider value
Web application with owned sessionsBetter Auth or a custom database sessionbetter-auth, custom-db-session
User authenticated by an external identity platformVerified JWTauth0, clerk, cognito
Trusted machine represented in the application data modelApplication API keyapi-key
Trusted server calling a hosted Apso serviceHosted service keyManage in the Apso Cloud API Keys view

Configure .apsorc

Add one top-level auth object. This JWT example maps the provider claims into Apso’s auth context:

.apsorc (excerpt)
{ "auth": { "provider": "cognito", "jwt": { "issuer": "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_example", "audience": "your-client-id", "algorithms": ["RS256"] }, "claims": { "userId": "sub", "email": "email", "workspaceId": "custom:workspace_id", "roles": "cognito:groups" } } }

Run apso generate, inspect the generated guard, and test invalid, valid, and cross-tenant requests.

Connect authorization

Use scopeBy for resource isolation and extensions for product-specific policies:

.apsorc (entity excerpt)
{ "name": "Project", "scopeBy": "workspaceId", "scopeOptions": { "injectOnCreate": true, "enforceOn": ["find", "get", "create", "update", "delete"], "bypassRoles": ["system_admin"] }, "fields": [ { "name": "name", "type": "text" } ] }

A valid token does not prove tenant membership or permission for a product action. Test tenant filters, role bypasses, and custom approval rules separately.

Client rules

  • Keep hosted service keys in a server environment.
  • Send user JWTs over HTTPS in the Authorization: Bearer header when using JWT auth.
  • Prefer HTTP-only, secure cookies for web sessions.
  • Store mobile user tokens in Keychain, Keystore, or the platform’s secure storage.
  • Never log raw session tokens or API keys.
Last updated on