~/Rev_

Identity and Secrets for a Platform, Not Just an App: Passkeys at the Apex and Tokens Bound to Their Owner

Two day-one choices that are painful to change later: where passkeys are registered, and how a stored bank token is tied to the user it belongs to.

work: 9 Nov 2026 · Built · DecoupleX Finance, DecoupleX, Auth, Cryptography, Security

No passwords

Sign-in is passkeys plus magic links (sent through Resend), via Better Auth. There's no password database to leak. During the beta there's an email allowlist and a rate limit stored in the database, so it holds across serverless instances. Every page and mutation re-checks the user server-side; the edge redirect is a convenience, not the security boundary.


Passkeys registered to the apex

A passkey is bound to a relying-party ID. I registered them to **decouplex.com**, not finance.decouplex.com. That way any subdomain, including a future accounts.decouplex.com that handles sign-in for every product, can use the same passkeys. Registering to the product subdomain would have meant every user re-enrolling the day a second product launched.


Tokens bound to their owner with AAD

Bank access tokens are encrypted with AES-256-GCM, using the user ID as additional authenticated data (AAD).

Why AAD: without it, anyone who can write to the database could copy user A's encrypted token into user B's row, and it would decrypt fine, quietly connecting B's account to A's bank. With the user ID as AAD, that ciphertext only decrypts under A's ID. Moved anywhere else, it fails authentication.

Keys are versioned. Each ciphertext records which key encrypted it, so keys can be rotated without re-encrypting everything at once. The rule: never delete an old key while any ciphertext still points at it.


What's next

This scheme moves under a key-management service as part of encrypting every financial field, not just tokens (Y01).


Lessons

  • Decide identity scope on day one. Moving a relying-party ID later costs every user a re-enrollment.
  • Encryption without context binding is incomplete. AAD costs nothing and stops ciphertext swapping.
  • Version your keys before you need to rotate them.

Sources: DecoupleX build log, "full app v0.2" and "domains and multi-product architecture" (9 Nov 2026)