Backoffice Auth Worker
Overview
The backoffice-auth Cloudflare Worker handles authentication for FloatMe’s internal admin console.
It is a thin pass-through proxy deployed to auth.backoffice.floatme.io (prod) and auth.backoffice.test.floatme.io (test).
The worker exposes a single route — POST /oauth/token — and forwards the request to a dedicated Auth0 tenant (floatme-backoffice) using the Resource Owner Password (password-realm) grant.
This keeps the Auth0 client_secret and realm details out of the admin client entirely; the client sends only a username and password.
The Auth0 connection used is Username-Password-Authentication (a standard database connection) on the floatme-backoffice tenant.
The issued token audience is https://api.backoffice.floatme.io (prod) or https://api.backoffice.test.floatme.io (test).
Source
cloudflare/workers/backoffice-auth/
| File | Purpose |
|---|---|
|
Entry point; route matching and |
|
Worker name, routes, and environment variables (non-secret) |
|
Uploads |
Routes
| Method | Path | Description |
|---|---|---|
|
|
Authenticate an admin user; returns Auth0 tokens on success |
|
|
All other paths return |
POST /oauth/token
| Field | Type | Notes |
|---|---|---|
|
string |
Admin user’s email or username |
|
string |
Admin user’s password |
| Parameter | Value |
|---|---|
|
|
|
|
|
|
|
|
|
Injected from |
|
Injected from |
The worker reads the client’s IP from CF-Connecting-IP (or x-real-ip) and forwards it to Auth0 via the auth0-forwarded-for header so that Auth0 anomaly detection can log the true origin IP.
On success, the Auth0 response (access token + refresh token + id token) is passed through to the caller unchanged.
Auth0 Configuration
| Setting | Prod value | Test value |
|---|---|---|
Auth0 tenant domain |
|
|
Auth0 connection |
|
|
Token audience |
||
Client ID |
See |
See |
The AUTH0_CLIENT_SECRET is stored in Cloudflare Secrets Manager and is never present in wrangler.toml.
Upload it with make secrets.backoffice-auth.host (see cloudflare/workers/backoffice-auth/secrets.sh).
|
Error Handling
| Condition | Response |
|---|---|
Missing or non-JSON body |
|
Missing |
|
Wrong path or method |
|
Auth0 rejects credentials |
Auth0 error response is passed through (e.g. |
Environment Variables
| Variable | Kind | Description |
|---|---|---|
|
var |
|
|
var |
Auth0 tenant base URL |
|
var |
Auth0 application client ID |
|
var |
Token audience for issued JWTs |
|
var |
Auth0 database connection name ( |
|
secret |
Auth0 application client secret (Cloudflare secret, not in toml) |
|
secret |
Datadog ingest key for structured log shipping |
Local Development
make backoffice-auth.local
This invokes:
wrangler dev cloudflare/workers/backoffice-auth/index.ts \
--env test \
-c cloudflare/workers/backoffice-auth/wrangler.toml
Unlike the other workers, backoffice-auth.local uses --env test explicitly so that the test Auth0 tenant
(floatme-backoffice-test.us.auth0.com) is used during local development.
The secrets AUTH0_CLIENT_SECRET and DATADOG_API_KEY must be available in your shell environment or a .dev.vars file in the worker directory (wrangler’s conventional local secrets file).
|
Wrangler starts a local HTTP server (default port 8787).
Send requests to http://localhost:8787/oauth/token with a JSON body containing username and password.
See Also
-
Architecture — Auth0 tenant layout and Cloudflare domain routing
-
Infrastructure — Terraform resources for this worker (
deploy/backoffice_auth_dns.tf) -
Auth0 Actions — Post-login actions that may apply to backoffice sessions