Skip to content

Endpoint Protection

This document provides a comprehensive overview of API endpoint protection in Fluxbase, including authentication methods, authorization models, and data security measures.


Fluxbase implements a multi-layered security model to protect API endpoints and sensitive data:

LayerProtectionDescription
Layer 1NetworkIP allowlists, rate limiting, CORS, TLS/HTTPS
Layer 2AuthenticationJWT tokens, client keys, service keys, CSRF protection
Layer 3AuthorizationRole-based access (RBAC), scope enforcement, feature flags
Layer 4DatabaseRow-Level Security (RLS), PostgreSQL policies
Layer 5DataPassword hashing, token hashing, audit logging
LevelSymbolDescription
Public🔓No authentication required
Optional🔑Auth optional, affects data visibility via RLS
Required🔒Authentication required
Admin🛡️Admin or dashboard_admin role required
Service🔐Service key + additional restrictions

Fluxbase supports four authentication methods, each suited for different use cases.

Use case: Web applications, mobile apps, authenticated users

Token delivery:

  • Authorization: Bearer <token> header
  • fluxbase_access_token cookie (httpOnly, Secure, SameSite=Strict)
  • token query parameter (WebSocket connections only)

Token types:

TypeLifetimePurpose
Access Token1 hourAPI access
Refresh Token7 daysObtain new access tokens

Claims extracted:

  • user_id, email, role
  • session_id, is_anonymous
  • user_metadata, app_metadata

Use case: Server-to-server integrations, automated scripts, third-party apps

Key delivery:

  • X-Client-Key: <key> header
  • clientkey=<key> query parameter

Key format: fbk_<base64_random_bytes>

Features:

  • Scoped permissions (granular access control)
  • Rate limiting per key
  • Expiration support
  • Revocation support
  • Usage tracking (last_used_at)

Storage: SHA-256 hash (only prefix exposed: fbk_xxxxxxxx)

Use case: Backend services, deployment pipelines, admin operations

Key delivery:

  • X-Service-Key: <key> header
  • Authorization: ServiceKey <key> header

Key format: sk_test_<random> or sk_live_<random>

Privileges:

  • Maps to service_role database role
  • Bypasses Row-Level Security (RLS)
  • Full access to all data

Storage: bcrypt hash (only prefix exposed)

Use case: Fluxbase dashboard administrators (platform management)

Separate auth system from application users:

  • Independent user table (dashboard.users)
  • Own JWT tokens with dashboard_admin role
  • Maps to service_role for database operations

RoleDatabase RoleRLS BypassDescription
anonanonNoUnauthenticated/anonymous users
authenticatedauthenticatedNoLogged-in application users
adminauthenticatedNoApplication administrators (still subject to RLS)
service_roleservice_roleYesBackend services with full access
dashboard_adminservice_roleYesPlatform administrators

Client keys can be granted specific scopes to limit their access:

CategoryScopesDescription
Tablesread:tables, write:tablesDatabase table operations
Storageread:storage, write:storageFile storage operations
Functionsread:functions, execute:functionsEdge function management/invocation
Authread:auth, write:authAuthentication operations
Client Keysread:clientkeys, write:clientkeysClient key management
Webhooksread:webhooks, write:webhooksWebhook configuration
Monitoringread:monitoringSystem monitoring data
Realtimerealtime:connect, realtime:broadcastWebSocket operations
RPCread:rpc, execute:rpcRemote procedure calls
Jobsread:jobs, write:jobsBackground job operations
AIread:ai, write:aiAI chatbot operations
Wildcard*All permissions (use with caution)
Endpoint TypeLimitWindowNotes
Global API100 req1 minPer IP address
Login10 req15 minPer IP
Signup10 req15 minPer IP
Password Reset5 req15 minPer IP
Magic Link5 req15 minPer IP
2FA Verification5 req5 minPer IP (strict)
Admin Login4 req1 minPer IP
Migrations API10 req1 hourPer service key
Client Key Requests1000 req1 minPer key
Authenticated Users500 req1 minPer user

CategoryPath PrefixEndpointsAuthRLSFeature Flag
Health/, /health, /ready3🔓 Public--
Auth/api/v1/auth/*~30🔑 Mixed--
REST API/api/v1/tables/*12🔒 RequiredYes-
Storage/api/v1/storage/*~20🔑 OptionalYesapp.storage.enabled
Functions/api/v1/functions/*~15🔑 Per-function-app.functions.enabled
Jobs/api/v1/jobs/*~10🔒 Required-app.jobs.enabled
AI/api/v1/ai/*~20🔑 Mixed-app.ai.enabled
RPC/api/v1/rpc/*~8🔑 Optional-app.rpc.enabled
Realtime/realtime3🔑 OptionalYesapp.realtime.enabled
Webhooks/api/v1/webhooks/*6🔒 Required--
Client Keys/api/v1/client-keys/*6🛡️ Admin--
Admin/api/v1/admin/*50+🛡️ Admin-Various
Migrations/api/v1/admin/migrations/*10🔐 Service-app.migrations.enabled

EndpointMethodAuthRate LimitDescription
/GET🔓 Public-Basic health check
/healthGET🔓 Public-Health status with DB check
/readyGET🔓 Public-Readiness probe
/metricsGET🔓 Public-Prometheus metrics (firewall recommended)

EndpointMethodAuthRate LimitDescription
/auth/csrfGET🔓 Public-Get CSRF token
/auth/signupPOST🔓 Public10/15minUser registration
/auth/signinPOST🔓 Public10/15minUser login
/auth/signoutPOST🔒 Required-User logout
/auth/refreshPOST🔓 Public10/1minRefresh access token
/auth/userGET🔒 Required-Get current user
/auth/userPATCH🔒 Required-Update user profile
/auth/magiclinkPOST🔓 Public5/15minRequest magic link
/auth/magiclink/verifyPOST🔓 Public-Verify magic link
/auth/password/resetPOST🔓 Public5/15minRequest password reset
/auth/password/reset/confirmPOST🔓 Public-Confirm password reset
/auth/otp/signinPOST🔓 Public5/15minRequest OTP
/auth/otp/verifyPOST🔓 Public5/5minVerify OTP
/auth/otp/resendPOST🔓 Public5/15minResend OTP
/auth/2fa/setupPOST🔒 Required-Setup TOTP 2FA
/auth/2fa/enablePOST🔒 Required-Enable 2FA
/auth/2fa/disablePOST🔒 Required-Disable 2FA
/auth/2fa/verifyPOST🔓 Public5/5minVerify 2FA code (login)
/auth/2fa/statusGET🔒 Required-Get 2FA status
/auth/user/identitiesGET🔒 Required-List linked OAuth identities
/auth/user/identitiesPOST🔒 Required-Link OAuth identity
/auth/user/identities/:idDELETE🔒 Required-Unlink OAuth identity
/auth/oauth/providersGET🔓 Public-List enabled OAuth providers
/auth/oauth/:provider/authorizeGET🔓 Public-OAuth authorization
/auth/oauth/:provider/callbackGET🔓 Public-OAuth callback
/auth/impersonatePOST🛡️ Admin-Start user impersonation
/auth/impersonate/anonPOST🛡️ Admin-Impersonate anonymous user
/auth/impersonate/servicePOST🛡️ Admin-Impersonate service role
/auth/impersonateDELETE🛡️ Admin-Stop impersonation
/auth/reauthenticatePOST🔒 Required-Reauthenticate user

All REST API endpoints require authentication and apply Row-Level Security.

EndpointMethodAuthScopesDescription
/tables/GET🛡️ Admin-List all tables
/tables/:tableGET🔒 Requiredread:tablesList rows (with RLS)
/tables/:tablePOST🔒 Requiredwrite:tablesCreate row
/tables/:tablePATCH🔒 Requiredwrite:tablesBatch update rows
/tables/:tableDELETE🔒 Requiredwrite:tablesBatch delete rows
/tables/:table/:idGET🔒 Requiredread:tablesGet single row
/tables/:table/:idPUT🔒 Requiredwrite:tablesReplace row
/tables/:table/:idPATCH🔒 Requiredwrite:tablesUpdate row
/tables/:table/:idDELETE🔒 Requiredwrite:tablesDelete row
/tables/:table/queryPOST🔒 Requiredread:tablesComplex query
/tables/:schema/:table/**🔒 Requiredread/write:tablesSchema-qualified operations

RLS Behavior:

  • anon role: Only sees data permitted by RLS policies for anonymous users
  • authenticated role: Sees data filtered by auth.uid() = user_id policies
  • service_role: Bypasses all RLS policies (full access)

Feature Flag: app.storage.enabled

EndpointMethodAuthScopesDescription
/storage/objectGET🔓 Public-Download signed object
/storage/bucketsGET🔑 Optionalread:storageList buckets
/storage/buckets/:bucketPOST🔑 Optionalwrite:storageCreate bucket
/storage/buckets/:bucketPUT🔑 Optionalwrite:storageUpdate bucket settings
/storage/buckets/:bucketDELETE🔑 Optionalwrite:storageDelete bucket
/storage/:bucketGET🔑 Optionalread:storageList files in bucket
/storage/:bucket/*GET🔑 Optionalread:storageDownload file
/storage/:bucket/*POST🔑 Optionalwrite:storageUpload file
/storage/:bucket/*HEAD🔑 Optionalread:storageGet file metadata
/storage/:bucket/*DELETE🔑 Optionalwrite:storageDelete file
/storage/:bucket/sign/*POST🔑 Optionalwrite:storageGenerate signed URL
/storage/:bucket/*/sharePOST🔑 Optionalwrite:storageShare file with user
/storage/:bucket/*/sharesGET🔑 Optionalread:storageList file shares
/storage/:bucket/stream/*POST🔑 Optionalwrite:storageStream upload
/storage/:bucket/chunked/**🔑 Optionalread/write:storageChunked upload operations

Feature Flag: app.functions.enabled

EndpointMethodAuthScopesDescription
/functions/GET🔒 Requiredread:functionsList functions
/functions/:nameGET🔒 Requiredread:functionsGet function details
/functions/:name/invokePOST🔑 Per-functionexecute:functionsInvoke function
/functions/:name/invokeGET🔑 Per-functionexecute:functionsInvoke (health checks)
/functions/:name/executionsGET🔒 Requiredread:functionsList executions
/functions/shared/**🔒 Requiredread/write:functionsShared module management

Per-function auth: Each function can be configured as public or authenticated.


Feature Flag: app.jobs.enabled

EndpointMethodAuthScopesDescription
/jobs/submitPOST🔒 Requiredwrite:jobsSubmit new job
/jobs/:idGET🔒 Requiredread:jobsGet job status
/jobs/:id/logsGET🔒 Requiredread:jobsGet job logs
/jobs/GET🔒 Requiredread:jobsList user’s jobs
/jobs/:id/cancelPOST🔒 Requiredwrite:jobsCancel job
/jobs/:id/retryPOST🔒 Requiredwrite:jobsRetry job

Feature Flag: app.ai.enabled

EndpointMethodAuthDescription
/ai/wsWS🔑 OptionalWebSocket for AI chat
/ai/chatbotsGET🔑 OptionalList public chatbots
/ai/chatbots/:idGET🔑 OptionalGet chatbot details
/ai/conversationsGET🔒 RequiredList user’s conversations
/ai/conversations/:idGET🔒 RequiredGet conversation
/ai/conversations/:idDELETE🔒 RequiredDelete conversation
/ai/conversations/:idPATCH🔒 RequiredUpdate conversation

Feature Flag: app.rpc.enabled

EndpointMethodAuthScopesDescription
/rpc/proceduresGET🔑 Optionalread:rpcList public procedures
/rpc/:namespace/:namePOST🔑 Optionalexecute:rpcExecute procedure
/rpc/executions/:idGET🔑 Optionalread:rpcGet execution status
/rpc/executions/:id/logsGET🔑 Optionalread:rpcGet execution logs

Feature Flag: app.realtime.enabled

EndpointMethodAuthScopesDescription
/realtimeWS🔑 Optionalrealtime:connectWebSocket subscriptions
/api/v1/realtime/statsGET🔒 Requiredrealtime:connectGet realtime statistics
/api/v1/realtime/broadcastPOST🔒 Requiredrealtime:broadcastBroadcast message

EndpointMethodAuthScopesDescription
/webhooks/GET🔒 Requiredread:webhooksList webhooks
/webhooks/:idGET🔒 Requiredread:webhooksGet webhook
/webhooks/:id/deliveriesGET🔒 Requiredread:webhooksList delivery history
/webhooks/POST🔒 Requiredwrite:webhooksCreate webhook
/webhooks/:idPATCH🔒 Requiredwrite:webhooksUpdate webhook
/webhooks/:idDELETE🔒 Requiredwrite:webhooksDelete webhook
/webhooks/:id/testPOST🔒 Requiredwrite:webhooksTest webhook

Client Keys Endpoints (/api/v1/client-keys/*)

Section titled “Client Keys Endpoints (/api/v1/client-keys/*)”
EndpointMethodAuthDescription
/client-keys/GET🛡️ AdminList client keys
/client-keys/:idGET🛡️ AdminGet client key
/client-keys/POST🛡️ AdminCreate client key
/client-keys/:idPATCH🛡️ AdminUpdate client key
/client-keys/:idDELETE🛡️ AdminDelete client key
/client-keys/:id/revokePOST🛡️ AdminRevoke client key

All admin endpoints require admin or dashboard_admin role.

EndpointMethodAuthRate LimitDescription
/admin/setup/statusGET🔓 Public-Check setup status
/admin/setupPOST🔓 Public5/15minInitial admin setup
/admin/loginPOST🔓 Public4/1minDashboard login
/admin/refreshPOST🔓 Public-Refresh dashboard token
/admin/logoutPOST🔒 Required-Dashboard logout
/admin/meGET🔒 Required-Get current admin
EndpointMethodAuthDescription
/admin/ddl/schemasGET🛡️ AdminList schemas
/admin/ddl/schemasPOST🛡️ AdminCreate schema
/admin/ddl/tablesGET🛡️ AdminList tables
/admin/ddl/tablesPOST🛡️ AdminCreate table
/admin/ddl/tables/:schema/:tableDELETE🛡️ AdminDelete table
/admin/ddl/tables/:schema/:tablePATCH🛡️ AdminRename table
/admin/ddl/tables/:schema/:table/columnsPOST🛡️ AdminAdd column
/admin/ddl/tables/:schema/:table/columns/:columnDELETE🛡️ AdminDrop column
/admin/sql/executePOST🛡️ AdminExecute raw SQL
EndpointMethodAuthDescription
/admin/usersGET🛡️ AdminList users
/admin/users/invitePOST🛡️ AdminInvite user
/admin/users/:idDELETE🛡️ AdminDelete user
/admin/users/:id/rolePATCH🛡️ AdminUpdate user role
/admin/users/:id/reset-passwordPOST🛡️ AdminReset user password
EndpointMethodAuthDescription
/admin/app/settingsGET🛡️ AdminGet app settings
/admin/app/settingsPUT🛡️ AdminUpdate app settings
/admin/system/settingsGET🛡️ AdminGet system settings
/admin/system/settings/*PUT🛡️ AdminUpdate system setting
/admin/settings/custom/**🛡️ AdminCustom settings CRUD
EndpointMethodAuthDescription
/admin/oauth/providersGET🛡️ AdminList OAuth providers
/admin/oauth/providers/:idGET🛡️ AdminGet provider
/admin/oauth/providersPOST🛡️ AdminCreate provider
/admin/oauth/providers/:idPUT🛡️ AdminUpdate provider
/admin/oauth/providers/:idDELETE🛡️ AdminDelete provider
/admin/auth/settingsGET🛡️ AdminGet auth settings
/admin/auth/settingsPUT🛡️ AdminUpdate auth settings
EndpointMethodAuthDescription
/admin/auth/sessionsGET🛡️ AdminList sessions
/admin/auth/sessions/:idDELETE🛡️ AdminRevoke session
/admin/auth/sessions/user/:user_idDELETE🛡️ AdminRevoke all user sessions
CategoryPathAuthFeature Flag
Functions/admin/functions/*🛡️ Adminapp.functions.enabled
Jobs/admin/jobs/*🛡️ Adminapp.jobs.enabled
AI/admin/ai/*🛡️ Adminapp.ai.enabled
RPC/admin/rpc/*🛡️ Adminapp.rpc.enabled
Extensions/admin/extensions/*🛡️ Admin-
Logs/admin/logs/*🛡️ Admin-
Monitoring/admin/monitoring/*🛡️ Admin-
Email/admin/email/*🛡️ Admin-

Migrations Endpoints (/api/v1/admin/migrations/*)

Section titled “Migrations Endpoints (/api/v1/admin/migrations/*)”

Feature Flag: app.migrations.enabled

Additional restrictions: IP allowlist, Service key required

EndpointMethodAuthRate LimitDescription
/admin/migrationsGET🔐 Service10/hourList migrations
/admin/migrationsPOST🔐 Service10/hourCreate migration
/admin/migrations/:nameGET🔐 Service10/hourGet migration
/admin/migrations/:namePUT🔐 Service10/hourUpdate migration
/admin/migrations/:nameDELETE🔐 Service10/hourDelete migration
/admin/migrations/:name/applyPOST🔐 Service10/hourApply migration
/admin/migrations/:name/rollbackPOST🔐 Service10/hourRollback migration
/admin/migrations/apply-pendingPOST🔐 Service10/hourApply all pending
/admin/migrations/syncPOST🔐 Service10/hourSync migrations

These endpoints are used by deployment pipelines and require IP allowlist verification.

EndpointMethodAuthIP AllowlistDescription
/admin/functions/syncPOST🔐 ServiceYesSync functions from filesystem
/admin/jobs/syncPOST🔐 ServiceYesSync jobs from filesystem
/admin/ai/syncPOST🔐 ServiceYesSync chatbots
/admin/rpc/syncPOST🔐 ServiceYesSync RPC procedures

flowchart TD
subgraph Request["Incoming Request"]
REQ[HTTP Request]
end
subgraph AuthCheck["Authentication Check"]
CHECK{Check Auth<br/>Headers/Cookies}
JWT[JWT Bearer Token]
CLIENTKEY[Client Key<br/>X-Client-Key]
SVCKEY[Service Key<br/>X-Service-Key]
COOKIE[Cookie<br/>fluxbase_access_token]
ANON[No Auth]
end
subgraph Validation["Token Validation"]
JWTVAL{Validate JWT<br/>HMAC-SHA256}
CKVAL{Validate Client Key<br/>SHA-256 Hash Lookup}
SVCVAL{Validate Service Key<br/>bcrypt Hash}
JWTVAL -->|Invalid/Expired| REJECT1[401 Unauthorized]
CKVAL -->|Invalid/Revoked| REJECT2[401 Unauthorized]
SVCVAL -->|Invalid| REJECT3[401 Unauthorized]
end
subgraph RoleAssignment["Database Role Assignment"]
AUTHROLE[authenticated<br/>Subject to RLS]
SVCROLE[service_role<br/>Bypasses RLS]
ANONROLE[anon<br/>Limited RLS Access]
end
subgraph Continue["Continue to Handler"]
HANDLER[Route Handler<br/>with RLS Context]
end
REQ --> CHECK
CHECK -->|"Authorization: Bearer"| JWT --> JWTVAL
CHECK -->|"X-Client-Key header"| CLIENTKEY --> CKVAL
CHECK -->|"X-Service-Key header"| SVCKEY --> SVCVAL
CHECK -->|"Cookie present"| COOKIE --> JWTVAL
CHECK -->|"None"| ANON --> ANONROLE
JWTVAL -->|Valid| AUTHROLE
CKVAL -->|Valid| AUTHROLE
SVCVAL -->|Valid| SVCROLE
AUTHROLE --> HANDLER
SVCROLE --> HANDLER
ANONROLE --> HANDLER
style REJECT1 fill:#e74c3c,color:#fff
style REJECT2 fill:#e74c3c,color:#fff
style REJECT3 fill:#e74c3c,color:#fff
style SVCROLE fill:#27ae60,color:#fff
style AUTHROLE fill:#3498db,color:#fff
style ANONROLE fill:#f39c12,color:#fff
flowchart TB
subgraph L1["Layer 1: Network Protection"]
IP[IP Allowlist<br/>Sync/Migration endpoints]
RATE[Rate Limiting<br/>Per IP/User/Key]
CORS[CORS Policy<br/>Allowed Origins]
TLS[TLS/HTTPS<br/>Encryption in Transit]
end
subgraph L2["Layer 2: Authentication"]
AUTH[Auth Middleware<br/>JWT/API Key/Service Key]
CSRF[CSRF Protection<br/>Token Validation]
HEADERS[Security Headers<br/>CSP, HSTS, X-Frame-Options]
end
subgraph L3["Layer 3: Authorization"]
ROLE[Role Check<br/>admin, authenticated, anon]
SCOPE[Scope Check<br/>API Key Permissions]
FEATURE[Feature Flags<br/>Module Enable/Disable]
end
subgraph L4["Layer 4: Database Security"]
RLS[Row-Level Security<br/>PostgreSQL Policies]
SETROLE["SET LOCAL ROLE<br/>anon/authenticated/service_role"]
CLAIMS["request.jwt.claims<br/>User Context"]
end
L1 --> L2 --> L3 --> L4
style L1 fill:#e74c3c,color:#fff
style L2 fill:#f39c12,color:#fff
style L3 fill:#27ae60,color:#fff
style L4 fill:#3498db,color:#fff
flowchart LR
subgraph Secure["Properly Protected (Low Risk)"]
PW[Password Hash<br/>bcrypt]
SESS[Session Tokens<br/>SHA-256 Hash]
CK[Client Keys<br/>SHA-256 Hash]
SVCK[Service Keys<br/>bcrypt Hash]
MAGIC[Magic Link Tokens<br/>SHA-256 Hash]
RESET[Password Reset Tokens<br/>SHA-256 Hash]
OAUTH[OAuth Tokens<br/>AES-256-GCM Encrypted]
end
subgraph Medium["Mitigated Risk (Medium)"]
OTP[OTP Codes<br/>5min Expiry + Max Attempts]
TOTP[TOTP Secrets<br/>Required for TOTP]
end
style Secure fill:#27ae60,color:#fff
style Medium fill:#f39c12,color:#fff
sequenceDiagram
participant C as Client
participant API as API Server
participant MW as Middleware Stack
participant DB as PostgreSQL
C->>API: POST /api/v1/tables/posts<br/>Authorization: Bearer <jwt>
API->>MW: 1. Rate Limiter
MW->>MW: Check request limits
API->>MW: 2. Auth Middleware
MW->>MW: Validate JWT token
MW->>MW: Extract user_id, role
API->>MW: 3. RLS Middleware
MW->>MW: Prepare RLS context
API->>DB: BEGIN TRANSACTION
API->>DB: SET LOCAL ROLE authenticated
API->>DB: SET request.jwt.claims = '{"sub":"user-123"}'
API->>DB: SELECT * FROM posts WHERE ...
Note over DB: RLS Policy Evaluated:<br/>auth.uid() = user_id
DB-->>API: Filtered Results (only user's posts)
API->>DB: COMMIT
API-->>C: 200 OK + Filtered Data

Data TypeStorage LocationStorage MethodRisk LevelExposure Impact
Passwordauth.users.password_hashbcrypt hash🟢 LOWCannot reverse hash
Session Access Tokenauth.sessions.access_token_hashSHA-256 hash🟢 LOWHash-only since migration 032
Session Refresh Tokenauth.sessions.refresh_token_hashSHA-256 hash🟢 LOWHash-only since migration 032
Client Keyauth.client_keys.key_hashSHA-256 hash🟢 LOWOnly prefix fbk_xxxxxxxx exposed
Service Keyauth.service_keys.key_hashbcrypt hash🟢 LOWOnly prefix exposed
OAuth Access Tokenauth.oauth_tokens.access_tokenAES-256-GCM encrypted🟢 LOWEncrypted at rest (requires FLUXBASE_ENCRYPTION_KEY)
OAuth Refresh Tokenauth.oauth_tokens.refresh_tokenAES-256-GCM encrypted🟢 LOWEncrypted at rest (requires FLUXBASE_ENCRYPTION_KEY)
Magic Link Tokenauth.magic_links.token_hashSHA-256 hash🟢 LOWHash-only since migration 039
Password Reset Tokenauth.password_reset_tokens.token_hashSHA-256 hash🟢 LOWHash-only since migration 039
OTP Codeauth.otp_codes.codePlaintext🟡 MEDIUM5-min expiry, max 3 attempts
TOTP Secretauth.users.totp_secretPlaintext🟡 MEDIUMRequired for TOTP algorithm
Backup Codesauth.users.backup_codesPlaintext array🟡 MEDIUMHashed after use
Data TypeStorage LocationRisk LevelNotes
Email Addressauth.users.email🟡 MEDIUMIndexed, exposed in API
User Metadataauth.users.user_metadata🟡 MEDIUMUser-editable, may contain PII
App Metadataauth.users.app_metadata🟡 MEDIUMAdmin-only, may contain sensitive info
OAuth Identity Dataauth.oauth_links.metadata🟡 MEDIUMFull provider response (name, avatar, etc.)
FieldJSON SerializationNotes
password_hashjson:"-"Never exposed
failed_login_attemptsjson:"-"Never exposed
is_lockedjson:"-"Never exposed
locked_untiljson:"-"Never exposed
Client Key (full)Return only on creationNever returned again
Session tokensNever in list operationsOnly returned on login
pie title Sensitive Data Risk Distribution
"Low Risk (Hashed/Encrypted)" : 9
"Medium Risk (Short-lived/Mitigated)" : 3

Security Configuration Verification:
- [ ] FLUXBASE_AUTH_JWT_SECRET is set (minimum 32 characters)
- [ ] FLUXBASE_ENCRYPTION_KEY is set (32 bytes for AES-256)
- [ ] FLUXBASE_SECURITY_SETUP_TOKEN is set for admin setup
- [ ] Rate limiting is enabled (app.security.enable_global_rate_limit)
- [ ] CORS is configured to specific origins (not wildcard *)
- [ ] TLS/HTTPS is enabled in production
- [ ] Debug mode is disabled in production (FLUXBASE_DEBUG=false)
- [ ] Webhook SSRF protection is enabled
- [ ] IP allowlists are configured for migrations/sync APIs
- [ ] Feature flags are reviewed for enabled modules
- [ ] Prometheus metrics endpoint is firewalled
MetricSourceAlert Condition
Failed login attemptsauth.users.failed_login_attempts> 5 per user
Account lockoutsauth.users.is_lockedAny lockout event
Rate limit violationsApplication logsSustained high volume
2FA recovery attemptsauth.two_factor_recovery_attemptsMultiple failures
Impersonation sessionsauth.impersonation_sessionsAny activity (audit)
Service key usageauth.service_keys.last_used_atUnexpected usage patterns
RLS bypass operationsQuery logsservice_role usage outside expected services

The following source files contain the implementation details for the security features documented above:

FilePurpose
internal/api/server.goRoute registration and middleware chains
internal/middleware/clientkey_auth.goClient key validation
internal/auth/jwt.goJWT handling
internal/middleware/rls.goRow-Level Security
internal/auth/scopes.goScope definitions
internal/auth/magiclink.goMagic link token hashing
internal/auth/password_reset.goPassword reset token hashing
internal/api/oauth_handler.goOAuth token encryption
internal/crypto/encrypt.goAES-256-GCM encryption utilities
internal/database/migrations/006_tables_auth.up.sqlAuth schema
internal/database/migrations/032_auth_security.up.sqlSession token hashing migration
internal/database/migrations/039_hash_security_tokens.up.sqlMagic link & password reset token hashing