Repository navigation
Description
Summary
A user's OAuth refresh token is deleted ten minutes after they stop syncing. Nothing about plugins or clients is involved — it follows from where the credential is stored.
Split out of #40 (item A) because it stands on its own: it is worth fixing whether or not the signature-auth work there happens.
The mechanism
Verified in integration-proxy/src/{proxy,security}.rs:
StoredCredential(proxy.rs:229-246) holds the realaccess_token,refresh_tokenandexpires_at.- It is sealed into the connection code's envelope and nowhere else.
security.rs:100creates exactly four tables —used_challenges,oauth_states,connection_codes,connection_handoffs. There is no persistent per-connection record. - Each proxied request
take_connection_codes (DELETE … RETURNING,security.rs:255), uses the credential, re-seals it into a fresh successor and stores that (proxy.rs:488-502). - Successor rows are inserted at
NOW() + INTERVAL '10 minutes'(security.rs:250) and swept on every write (security.rs:245).
So the TTL resets on each rotation — an actively syncing client never expires. But once a client goes idle past ten minutes, the row is swept, and that row was the only copy of the sealed refresh token. Recovery is a full re-OAuth.
Why it's worth fixing on its own
- A refresh token is a long-lived grant the user consented to. Ending it because nobody synced over lunch is a surprising place for it to go, and the user is given no signal that it happened until the next sync fails.
- The same applies to any break in the chain, not just idleness. A dropped response spends the code client-side and rotates it server-side; the reply carrying the successor is the only copy. The source already acknowledges this shape for the handoff case — "Consume before dispatch: a lost response may have spent the handoff code" — but for connection codes the cost is the grant itself, not a retry.
- It couples grant durability to a transport detail. Single-use rotation is a reasonable property for a bearer token. It is not a reasonable lifecycle for an OAuth grant, and right now they are the same object.
Proposed
A persistent connections table: stable connection_id, the sealed StoredCredential, the owning user_id (DID), platform, created_at, last_used_at. Not deleted on use.
Rotating codes keep working unchanged — a connections row simply becomes the source of truth they are minted from, instead of being the only place the credential lives. Additive, no client change required.
Open questions
- Idle lifecycle for a
connectionsrow. Something long (weeks) withlast_used_at, so dead grants are still cleaned up, rather than no expiry at all. - Whether existing in-flight connection codes need a migration or can simply age out.
- Revocation surface:
is_revoked(tenant_id, user_id)exists (proxy.rs:113-117); a persistent connection makes per-connection revocation expressible too.
Activity
fix(integration-proxy): keep connection codes for 30 idle days, not 1…
Merge pull request #61 from ontola/claude/issue-42-connection-code-id…