Skip to Content
SPAPS is proprietary hosted SaaS. Paid access required; pre-1.0 contracts may change. Terms and access
GuidesAuth And Local Mode

Auth And Local Mode

SPAPS auth is easiest to reason about as two stacked checks. First, the request identifies the calling application with an API key. Second, the request identifies the user with a JWT, or in local mode with a selected local persona. Most confusing auth bugs come from mixing those two identities.

Mental Model

When To Use Which Layer

NeedUse
Identify the client appget_application
Require a signed-in userget_current_user
Allow signed-in or anonymous behaviorget_optional_user
Require admin accessrequire_admin_user or require_roles
Develop without real authDEVELOPMENT_ENVIRONMENT=local and local-mode helpers

Local Vs Production Checklist

ModeFirst commandExpected signalStop if
Local persona modecurl -fsS http://localhost:3301/health/local-modeLocal mode is named, with the local test app hintsSPAPS_LOCAL_MODE and DEVELOPMENT_ENVIRONMENT disagree
CLI local runtimenpx spaps quickstart --jsonOutput names local-mode or provisioning hintsThe quickstart cannot identify the runtime mode
Production authcurl -fsS http://localhost:3301/health/readyReadiness passes without local bypass hintsLocal bypass is enabled in a production-shaped environment
Browser publishable keyUse the frontend origin that owns the appThe key is constrained by route and originA publishable key works from an unlisted origin

Example Route

from typing import Annotated from fastapi import Depends, APIRouter from spaps_server_quickstart.middleware.spaps_deps import get_current_user router = APIRouter() @router.get("/me") async def me(user: Annotated[object, Depends(get_current_user)]) -> dict[str, str]: return {"user_id": str(user.id)}

Common Mistakes

A valid JWT is not enough if it was minted for a different application. get_current_user enforces token application matching against the API-key application.

  • Treating a publishable key as a server key. Publishable keys are origin and endpoint constrained.
  • Forgetting that local mode still resolves explicit real API keys.
  • Enabling local auth bypass in an environment that startup validation treats as production.

Next