Architecture
System Context
The Edge service sits at the Cloudflare layer between external clients (mobile app, web, backoffice) and FloatMe’s internal platform. All inbound traffic is protected by Cloudflare’s WAF before reaching any worker. Workers proxy requests to Auth0 for identity operations, call internal services over IAM-signed HTTP, and integrate with third-party platforms for fraud detection, analytics, and SMS delivery.
Inbound Traffic
| Domain | Worker | Purpose |
|---|---|---|
|
Auth ( |
Auth0 proxy for mobile app: login, signup, MFA, social auth, session tokens, user info, and analytics tracking. |
|
Auth ( |
Same worker, test environment Auth0 tenant. Castle blocking disabled. |
|
SMS ( |
Text-Me-The-App endpoint called from floatme.com and paid ad campaigns. |
|
SMS ( |
Same worker, test environment. |
|
Links ( |
Deeplink redirect and |
|
Links ( |
Same worker, test environment. |
|
Backoffice Auth ( |
Auth0 proxy for the internal admin console (password-realm grant against the |
|
Backoffice Auth ( |
Same worker, test tenant. |
Outbound Traffic
| Worker | Destination | Description |
|---|---|---|
Auth |
Auth0 ( |
All OAuth2/OIDC operations: token issuance, user creation, password management, MFA enrollment, social authentication, management API calls. |
Auth |
User Service |
IAM-signed POST to |
Auth |
Castle ( |
Pre-login and pre-signup risk scoring. Sends device fingerprint and user context; blocks or challenges on |
Auth |
Segment |
|
Auth |
Datadog |
Structured logs shipped via |
Backoffice Auth |
Auth0 ( |
Password-realm token request on behalf of backoffice console users. |
Backoffice Auth |
Datadog |
Structured logs. |
SMS |
Twilio |
Sends SMS messages via the Twilio Messaging API using a pre-configured messaging service SID. |
SMS |
Datadog |
Structured logs. |
Links |
Datadog |
Structured logs. |
External Services
Auth0
Auth0 is the identity provider for all FloatMe authentication. The auth worker proxies client requests to Auth0’s Authentication API and Management API, keeping credentials server-side and enforcing FloatMe-specific logic (Castle checks, user status validation) before token issuance.
| Usage | Detail |
|---|---|
Authentication API |
Token issuance, user creation, password management, MFA enrollment and challenge/submit, social authentication. |
Management API |
Reading and updating user metadata (e.g. unblocking paused users). Uses a separate management client credential. |
Tenants |
|
Workers |
Auth worker (primary), Backoffice Auth worker. |
| Secret Name | Purpose |
|---|---|
|
Client secret for the mobile Auth0 application. |
|
Database connection name (e.g. |
|
Audience for access tokens. |
|
Expected issuer for JWT validation. |
|
Audience for MFA-scoped tokens. |
|
Client ID for the Management API client. |
|
Client secret for the Management API client. |
|
Audience for Management API tokens. |
| Secret Name | Purpose |
|---|---|
|
Client secret for the backoffice Auth0 application. |
Castle
Castle provides device-based fraud and abuse detection.
The auth worker calls Castle before login and signup operations, sending a fingerprint token extracted from the request.
If Castle returns DENY and ENABLE_CASTLE_BLOCKING is true (prod only), the request is rejected before reaching Auth0.
A CHALLENGE result is logged but does not block in the current implementation.
| Usage | Detail |
|---|---|
Pre-login check |
|
Pre-signup check |
|
Post-login signal |
|
Workers |
Auth worker only. |
| Secret Name | Purpose |
|---|---|
|
API key for authenticating requests to |
Segment
Analytics events are forwarded through the FloatMe metrics service (an internal API Gateway endpoint) rather than calling Segment directly.
The floatmetric-track handler in the auth worker receives tracking payloads from the mobile app and forwards them via IAM-signed request.
| Usage | Detail |
|---|---|
floatmetric-track |
Proxies mobile analytics events to the FloatMe metrics endpoint ( |
Workers |
Auth worker only. |
SEGMENT_WRITE_KEY and SEGMENT_BASE_URL are defined in the shared Env interface for potential direct Segment use but the current auth worker routes through the metrics endpoint.
|
Twilio
The SMS worker uses Twilio to deliver the Text-Me-The-App message.
Phone number validation uses the phone library to reject non-US numbers before the Twilio API is called.
The worker enforces CORS origin allowlisting to prevent abuse from unauthorized domains.
| Usage | Detail |
|---|---|
SMS delivery |
Sends a campaign-specific message via the Twilio Messaging API ( |
Workers |
SMS worker only. |
| Secret Name | Purpose |
|---|---|
|
Auth token for Twilio account |
Datadog
All four workers emit structured logs to Datadog via DatadogLogger.
Logs are queued in-memory during the request and flushed via DatadogLogger.sendQueuedLogs() in the worker’s ctx.waitUntil() callback, ensuring log delivery does not block the response.
| Usage | Detail |
|---|---|
Log shipping |
All structured log events (info, warn, error) are batched and POSTed to |
Service tagging |
Each worker registers with a service name in the format |
Workers |
All workers (Auth, Backoffice Auth, SMS, Links). |
| Secret Name | Purpose |
|---|---|
|
API key for authenticating log ingestion requests. |
Request Handling Pattern
All workers share a common set of helper modules located in cloudflare/helpers/.
request-handler.ts
The central dispatch wrapper.
Every worker’s fetch() handler calls handleRequest(logger, request, env, handlerFn).
It executes the given handler function and catches any unhandled exceptions, returning a 500 Internal Server Error response and logging the error to Datadog.
This ensures no exception can leak an unformatted error to the client.
export default async function handleRequest(
logger: DatadogLogger,
request: Request,
env: Env,
handler: Function,
): Promise<any> {
try {
return handler(logger, request, env);
} catch (err) {
logger.error(err, 'unexpected error handling the request');
return createHttpResponse('Internal Server Error', StatusCodes.INTERNAL_SERVER_ERROR);
}
}
http-error.ts
Defines HttpError, a typed error class that carries an HTTP status code and optional structured details payload.
Handlers throw HttpError instances for expected failure cases (e.g. invalid input, upstream Auth0 errors).
request-handler.ts catches any remaining untyped exceptions as a safety net.
http-response.ts
A thin wrapper around the Cloudflare Workers Response constructor.
createHttpResponse(body, status) sets content-type: application/json and serialises non-string bodies via JSON.stringify.
All handlers return responses through this function for consistent formatting.
datadog-logger.ts
A singleton-per-service logger class.
DatadogLogger.getDatadogLogger(env, serviceName) returns a cached instance keyed on {WORKER_ENV}-{serviceName}.
Logs are queued in-memory with info(), warn(), and error() methods and flushed in bulk to the Datadog HTTP intake API at the end of each request via DatadogLogger.sendQueuedLogs(env).
The withValues() method attaches persistent key-value pairs (e.g. request context) to all subsequent log entries from the same instance.
Secrets Management
How Secrets Are Uploaded
Each worker has a secrets.sh script in its directory (e.g. cloudflare/workers/auth/secrets.sh).
The script reads secrets from shell environment variables and pushes them to Cloudflare using wrangler secret put:
echo $AUTH0_APP_CLIENT_SECRET | wrangler secret put AUTH0_CLIENT_SECRET --env $FLOATME_ENVIRONMENT
echo $CASTLE_CLIENT_SECRET | wrangler secret put CASTLE_CLIENT_SECRET --env $FLOATME_ENVIRONMENT
echo $DATADOG_API_KEY | wrangler secret put DATADOG_API_KEY --env $FLOATME_ENVIRONMENT
# ... additional secrets
$FLOATME_ENVIRONMENT must be set to prod or test before running.
The top-level Makefile provides make secrets targets that invoke the appropriate secrets.sh scripts.
How Secrets Are Injected at Runtime
Cloudflare injects secrets as environment bindings at worker startup.
They are accessible on the env object passed to each worker’s fetch(request, env, ctx) handler and typed in cloudflare/helpers/env.ts.
Non-secret configuration (base URLs, feature flags, SIDs) is declared in wrangler.toml under [env.prod.vars] and [env.test.vars] — these are plain environment variables visible in the wrangler config and suitable for non-sensitive values only.
Related Pages
-
Home — Worker map and Auth0 components overview
-
Infrastructure — Terraform resources, DNS, Auth0 tenant config, deployment
-
Feature Summary — Capability reference by category
-
Auth Worker — Handler reference and Castle integration details
-
SMS Worker — SMS delivery, validation, and CORS handling
-
Links Worker — Deeplink routing and
.well-knownhosting -
Backoffice Auth Worker — Admin console authentication