Skip to content

How It Works

A Twilio code (and TOTP for Bubbl staff) opens a session. Redfly issues 15-minute Ed25519-signed PASETO tokens and publishes revocations and telemetry over Pulsar.

Sign-in flow

  1. POST /v1/auth/code with {phone}: Redfly normalizes the number to E.164, applies rate limits, generates a 6-digit code, stores its HMAC and sends it through Twilio.
  2. POST /v1/auth/verify with {phone, code}: the code is valid for 10 minutes and allows 5 wrong attempts.
  3. If the user holds a Bubbl staff role, Redfly requires POST /v1/auth/totp before issuing a session.
  4. Redfly creates a sign-in session (12 h idle, 30 days at most) and returns a refresh cookie and a PASETO.

Tokens and keys

  • Format: PASETO v4.public, signed with Ed25519, valid for 15 minutes.
  • Claims: sub, sid, ten, app, iat, exp, jti.
  • Refresh: POST /v1/auth/refresh with the session cookie returns a new PASETO.
  • GET /v1/auth/keys publishes the current and previous Ed25519 public keys with key ids. Apps and the WordPress plugin cache them and refetch on an unknown key id.
  • The signing key path (REDFLY_AUTH_KEY_PATH) holds the current key plus the previous one during rotation.

Revocation

Signing out, an admin revocation or a suspension publishes {scope: token|session|user, id, revoked_before, exp} to persistent://odssbc/redfly/revocations, keyed by user id. Each app holds a deny-list in SeaWave until each entry’s exp.

Device app passwords

  • POST /v1/auth/app-passwords requires a full sign-in and returns a random secret once.
  • Only an Argon2id hash is stored. Each password has a name and is scoped to sync:devices.
  • Bubbl verifies DAV Basic credentials through POST /v1/auth/app-passwords/verify (service-to-service mTLS) and caches the result briefly.
  • DELETE /v1/auth/app-passwords/{id} revokes a password.

Authorization

The Shiro realm RedflyTokenRealm verifies the PASETO and loads roles from user_role.

RolePermissions
platform-adminAll permissions, across all tenants
tenant-admindb:*:read, db:*:write, telemetry:read and users:write, within the user’s own tenants
operatortelemetry:read, across all tenants
userNo db:* permissions

/v1/db/{entity} requires db:<entity>:read (GET) or db:<entity>:write (PUT). Results are limited to the caller’s tenants, apart from platform-admin.

REST interfaces

MethodPathAuthPurpose
POST/v1/auth/codenone, rate-limitedSend a sign-in code
POST/v1/auth/verifynone, rate-limitedVerify the code, then start a session or ask for TOTP
POST/v1/auth/totppending sessionSecond factor for Bubbl staff
POST/v1/auth/totp/enrollsessionEnroll TOTP (returns provisioning URI once)
POST/v1/auth/refreshsession cookieIssue a new PASETO
POST/v1/auth/logoutsessionEnd the session and publish a revocation
GET/v1/auth/keysnoneCurrent and previous Ed25519 public keys
POST/GET/DELETE/v1/auth/app-passwords[/{id}]sessionManage device app passwords
POST/v1/auth/app-passwords/verifyservice mTLSBubbl DAV credential check
POST/v1/telemetryPASETO or WP site client secretValidate events and publish them to Pulsar
GET/PUT/v1/db/{entity}PASETO plus db:<entity>:*Master-database access
POST/v1/sync/bubblservice mTLS (FairFeather)Apply outbox entries idempotently
POST/v1/notify/smsservice mTLS (Bubbl, Caulight)Send an SMS to a user from a named template

Data layer

Keyspace redfly, using NetworkTopologyStrategy {<dc>: 3} and LOCAL_QUORUM. The CQL is written by hand and is not generated.

TableHolds
users, users_by_phoneUser id (UUIDv7), E.164 phone, display name, status; phone lookup written with LWT
tenants, tenants_by_app_keyTenants across apps (bubbl or caulight)
tenant_members, user_roleTenant membership and platform roles
sign_in_codesCode HMAC, attempts and expiry (TTL 600)
code_send_countsPer-phone and per-IP send counts (TTL 3600)
sessionsSign-in sessions with last-seen, expiry, revocation, user agent and IP hash
totp_credentialsEncrypted TOTP secret and wrapped key id
app_passwordsName, Argon2id hash, created and last-used times
bubbl_recordsCopies of Bubbl records as JSON, encrypted fields left as ciphertext
outbox_receiptsIdempotent delivery records
auditsActor, action, entity and record id per day
schema_historyApplied CQL and Kotlin data-migration steps

Messaging and telemetry

  • Publishes persistent://odssbc/redfly/revocations, keyed by user id.
  • Publishes persistent://odssbc/redfly/telemetry, keyed by tenant id.
  • Telemetry events follow a fixed schema: event_id (UUIDv7), ts, app, app_version, tenant_id, user_hash, session_hash, name, level, duration_ms and attrs (at most 32 keys, 256 characters each).
  • A user_hash must be 64 hex characters (HMAC-SHA256 of the Redfly user id with a rotating per-tenant salt).

Ports

PortBindPurpose
8443pod IPHTTPS REST API and health
7000pod IP, TLSCassandra internode traffic
9042127.0.0.1CQL native (app → embedded Cassandra)
2181127.0.0.1SunLink ZooKeeper protocol (Curator)
7480pod IP, mTLSSunLink Raft ring between replicas
6379127.0.0.1SeaWave RESP (Spring Session, deny-list)
7481pod IP, mTLSSeaWave peer replication

Key environment variables

VariablePurpose
REDFLY_CASSANDRA_DATA_DIR, _DC, _SEEDSEmbedded Cassandra data directory, datacenter and seed pods
REDFLY_AUTH_KEY_PATHEd25519 signing keys for PASETO
REDFLY_AUTH_TTL_SECONDSToken lifetime, default 900
REDFLY_SESSION_IDLE_SECONDS / _MAX_SECONDSSession limits, default 43200 and 2592000
REDFLY_TWILIO_ACCOUNT_SID, _AUTH_TOKEN_FILE, _FROMTwilio account, mounted token and sender
REDFLY_OPENBAO_ADDR, _TRANSIT_KEYOpenBao Transit for the wrapped data key
REDFLY_SUNLINK_CLUSTERSunLink peers
REDFLY_PULSAR_SERVICE_URLPulsar broker (pulsar+ssl://)
REDFLY_SHIRO_CONFIGShiro configuration file path