Backend identity contracts
Keep existing authentication while issuing Relay-specific assertions.
Reviewed: 2026-11-08.
Your application can retain its existing authentication. Its backend verifies the session or intended API token, checks current member eligibility, and issues the ES256 assertion for the OpenE2EE Signal Protocol Relay. A provider token does not grant Relay account-management authority.
Evidence levels
The Better Auth recipe has a local real-provider test path and an explicit actual-Relay verifier path. Their recorded results must accompany acceptance. They do not prove a hosted provider deployment.
The other rows below describe backend contracts from primary provider documentation. They are not tested vendor adapters or native Relay profiles. Hosted acceptance remains unverified for every row.
These backend routes issue custom-token assertions. A native Clerk or Firebase profile verifies the provider token without a backend route.
| Existing login | Backend verification | Stable mapping and standing | Evidence |
|---|---|---|---|
| Custom sessions | Verify the application's server session on each issuance request. | Preserve the installed opaque member ID and encoding. If the issuer serves more than one tenant, sign a tenant-qualified subject. Check current membership in the server-selected tenant. | Issuer recipe. Local issuer tests do not verify the application's session adapter. |
| Better Auth | Actual server auth.api.getSession with the cookie cache disabled. | Stateful session revocation plus current application membership in a server-selected tenant. | Local recipe tests; hosted unverified. |
| Clerk backend | Use the supported server SDK to verify a session token for a human user. Check the intended instance and authorized parties. | Map the verified issuer and user sub to an immutable local member. Check current application membership in the server-selected tenant. | Session verification. Signed token verification alone does not prove immediate provider-session revocation. Hosted unverified. |
| Firebase backend | Verify a client ID token through the Admin SDK for the expected project. Use its tenant-aware client for the selected tenant. Check revocation when the policy requires it. | Map the verified project, tenant and uid to an immutable local member. Check current application standing. | ID token verification and tenant verification. Offline verification alone does not check revocation. Hosted unverified. |
| WorkOS AuthKit | Supported sealed-session helper and its authentication result. | Map the verified user in the intended Organization. Check current application membership; cached role claims alone are insufficient. | Documented contract; hosted unverified. |
| Auth0 | Current server Auth0Client.getSession; validate intended API tokens when that is the application's contract. | Qualify the immutable provider subject by issuer/tenant, then check current application membership. | Documented contract; hosted unverified. |
| Supabase Auth | Supported server verification; use getUser when current user data is needed. Do not authorize from embedded getSession user data. | Map the verified user to the application tenant. Check current standing separately. getUser alone does not guarantee immediate session revocation. | Documented contract; hosted unverified. |
| Amazon Cognito | Supported verifier checks issuer, expiry, token_use, and the applicable access client_id or ID-token aud. | Qualify the user by pool/issuer. Check current application membership and disablement policy. | Documented contract; hosted unverified. |
| Microsoft Entra ID | Validate the exact API audience, intended tenant, and actor. | A tenant-qualified user mapping must distinguish users from service principals. tid or oid possession alone grants no membership. | Documented contract; hosted unverified. |
| Okta | Supported backend verifier with the intended issuer and API audience. | Qualify the subject by issuer. Check current application eligibility. | Documented contract; hosted unverified. |
| Keycloak | Supported backend verification or confidential-client introspection under the application's policy. | Qualify the subject by realm/issuer and intended audience. Check current application eligibility. | Documented contract; hosted unverified. |
| SAML and opaque OAuth tokens | The backend or trusted broker verifies the login under its protocol. Do not parse an opaque token as a JWT. | Map the verified issuer and human subject to the immutable local member. Check current application membership. | Generic backend compatibility only. Relay accepts the resulting Relay assertion, not the original SAML response or opaque token. Hosted unverified. |
Do not forward an ordinary ID token, API access token, or arbitrary JWKS URL as a Relay assertion. The configured custom-token profile accepts its exact issuer, audience, algorithm, subject claim, and public keys.
Own the member mapping
Assign an opaque, immutable, non-reassigned local member ID. The Better Auth broker signs JSON.stringify([tenantId, memberId]) under its configured issuer. This encoding qualifies the subject by tenant and preserves delimiter boundaries. Preserve the tuple and encoding for existing accounts. Never use a matching email as proof that two provider accounts belong to one member.
Link multiple providers only after authenticating both accounts and checking application authorization. Preserve the application member ID when a phone number, username, display name, or login provider changes. Refuse tenant substitutions. Deny guest issuance unless an explicit supported member policy covers those guests.
The SDK's username and optional PNI helpers do not provide a hosted phone-verification service or username directory. Keep phone and username login checks in your application authentication and bind the stable member ID.
A verified session identifies the caller. Your current membership store decides eligibility. Select the tenant from trusted application routing or server configuration. Do not let a body field choose a different tenant, signing profile, or member.
Own assurance and keys
Every backend row uses verified authentication and current application membership for normal assurance. These compatibility declarations supply no recent sign-in or second-factor receipt.
Each provider path must identify the actual authentication event that supports recent or step-up assurance. A refreshed token, session extension, or cached claim cannot supply missing authentication evidence. If the backend lacks that evidence, refuse the requested assurance.
Keep the Relay assertion signing key separate from provider credentials, device authentication keys, and Signal identity keys. Retain verification-key overlap for outstanding assertions and clock tolerance. Test key removal before rollout. Key removal does not revoke existing Relay device proofs.
Loss of membership and provider events
Every backend row uses the same lifecycle limit. Provider verification and assertion issuance do not automatically suspend an existing Relay device.
Refuse new assertions when the authoritative session or application membership is no longer valid. Existing devices require a supported privileged lifecycle operation to stop identified access. Recovery replaces encryption identity and is not a disable operation. A sender identity cannot cancel anonymous capabilities that do not contain it.
To stop identified access on existing devices, follow Suspend an identified account. This issuance recipe does not expose private controls or service credentials. Hosted lifecycle acceptance remains open.
This recipe includes no provider event adapter. Before adding one, specify signature verification, issuer/tenant binding, event ordering, deduplication, exact member mapping, retries, and reconciliation. Do not infer current standing from delivery order or an event's absence. Preserve the exact unresolved lifecycle attempt across a lost response.
Suspend an identified account
Refusing new assertions does not stop existing devices. Use this privileged procedure to suspend identified access for one member. Use CLI 4.0.0 or later. Examples use Sandbox. Set --env to the intended environment.
Before you start:
- Link the project.
- Sign in as a real Organization member with environment management permission.
- Verify the selected Organization, project, and environment.
Ordinary provider sessions, tokens, and Relay assertions grant no management authority.
Target
This example target uses the Better Auth encoding:
{"kind":"subject","subject":"[\"tenant-id\",\"member-id\"]","profileSource":"installed"}subject is the exact string value of the configured subject claim that your issuer signs. Relay matches a registered account only when this string is identical. The encoding depends on the issuer:
- The custom-token issuer signs
session.memberId. Its subject is the plain member ID. - The Better Auth broker signs
JSON.stringify([tenantId, member.memberId]). Its subject is that JSON array string.
Use the same encoding and the same trusted IDs as your issuer. Never accept the subject from a client. Never derive it from an email or handle. Set profileSource to installed or migration-target. It must match the actual configured source.
A real target is private. Do not put it on the command line. Keep it out of shell history, logs, and retained files. Your authorized backend process writes one target JSON to standard input for each target, dry-run, or new apply command.
Suspend
- Resolve the target:
oe identity lifecycle target --target-stdin --env sandbox. - Preview the change:
oe identity lifecycle suspend --target-stdin --dry-run --env sandbox. - Continue only when the output shows the account you intend. That is,
applicationKindisbound-account, and the output includeseffectiveAccountState.unbound-subjectidentifies an unbound subject: no registered account uses this subject. First check the subject encoding for your issuer. An apply does not change the existing devices of a member whose subject has a different encoding. It records a suspension for this exact subject. Relay applies that suspension if an account later registers under this subject. A fenced target read fails withIDENTITY_RESULT_INVALID. Relay fences the read when the subject has no account and no earlier lifecycle apply. For a subject that no account has used, that failure most often means that the subject string does not match the encoding of your issuer. Enter the target again with the other encoding before you treat it as a Relay fault. - Apply with
oe identity lifecycle suspend --target-stdin --env sandbox.
Target and dry-run commands only observe. They do not prepare or apply a lifecycle operation.
The server holds each lifecycle operation. The CLI keeps no local operation state. An apply needs no first-use flag. CLI 4.0.0 removed the local operation store and its first-use flags. To move scripts and pending operations from an earlier CLI, follow Upgrade to 4.0.
Production changes require explicit confirmation. Use --yes only after you review the exact change. --yes records consent. It grants no extra permission.
Unresolved results
When an apply stops after the CLI sends it, the output reports the operation ID and the next command. Record the operation ID. Replace ID with it in these commands:
oe identity operation status --kind lifecycle --operation-id ID --env sandbox
oe identity operation resume --kind lifecycle --operation-id ID --env sandboxUse status for a read-only check. Without --operation-id, status needs --target-stdin and reports the current operation of the bound account. resume continues the same operation ID and requested state. It accepts no target. For an original suspension, continuation keeps that request. It does not request active state. See lifecycle and recovery for operation custody details.
Activate
Settle the original operation first. Activation is a new request for active state. Current guards apply again. Permanently revoked devices remain revoked.
- Read the target again with
oe identity lifecycle target --target-stdin --env sandbox. - Preview activation with
oe identity lifecycle activate --target-stdin --dry-run --env sandbox. - Continue only when the output shows the account you intend. That is,
applicationKindisbound-account, and the output includeseffectiveAccountState.unbound-subjectidentifies an unbound subject: no registered account uses this subject. First check the subject encoding for your issuer. An apply does not change the existing devices of a member whose subject has a different encoding. An apply that completes records active state for this exact subject. Relay applies that state if an account later registers under this subject. A fenced target read fails withIDENTITY_RESULT_INVALID. Relay fences the read when the subject has no account and no earlier lifecycle apply. For a subject that no account has used, that failure most often means that the subject string does not match the encoding of your issuer. Enter the target again with the other encoding before you treat it as a Relay fault. - Apply with
oe identity lifecycle activate --target-stdin --env sandbox.
Effects and evidence
Suspension retains data and devices. It refuses new registration, linking, renewal, recovery, and identified requests. Anonymous capabilities and issued assets keep their separate policy and expiry. Recovery replaces the encryption identity. It does not disable membership.
A receipt, acknowledgment, or count does not prove current service, member mapping, or application integration. serviceReadiness stays unverified. Hosted lifecycle acceptance remains unverified.
Application acceptance
- Verify two different members receive distinct Relay bindings.
- Verify repeat authentication preserves one member's binding.
- Refuse missing, expired, revoked, disabled, and foreign-tenant sessions.
- Verify a retained session-cache cookie cannot bypass revocation.
- Refuse recovery assurance without actual authentication evidence.
- Verify phone and username changes preserve the member mapping.
- Test encrypted exchange between real devices before rollout.
- In Sandbox, suspend a test member, verify that Relay refuses its existing device, then activate it explicitly.
The SDK package does not include these provider adapters or their dependencies. Use supported provider libraries on your backend. The application remains responsible for its membership, authentication evidence, signing keys, and deprovisioning policy.