Skip to content

integration-proxy: keep connection codes for 30 idle days, not 10 minutes (#42) - #61

Merged
michielbdejong merged 1 commit into
mainfrom
claude/issue-42-connection-code-idle-ttl
Sep 23, 2026
Merged

michielbdejong merged 1 commit into
mainfrom
claude/issue-42-connection-code-idle-ttl

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

Closes #42

Root cause. store_connection_code (integration-proxy/src/security.rs) stored every connection code with a 10-minute expiry, and deleted expired rows on insert. That row is the only server-side copy of the sealed credential, refresh token included. An actively syncing client never hit the limit, because each proxied request rotates the code. But after 10 idle minutes the grant was destroyed, and the user had to redo OAuth.

Change.

  • Adds pub const CONNECTION_CODE_IDLE_DAYS: i32 = 30. Connection codes are now stored with NOW() + make_interval(days => $3).
  • Codes stay single-use and are still replaced on every request, so this is an idle timeout from last use.
  • Handoff codes (5 min) and OAuth states/nonces (10 min) are unchanged. No schema or client change: codes already issued get the new lifetime the next time they are used.
  • SECURITY.md states the new lifetime and its trade-off.

Trade-off, open for discussion in #54. A leaked but unused code is now valid for up to 30 days instead of 10 minutes. Because codes are single-use, a thief who uses one first breaks the real client's next request, which makes the theft noticeable. Still not handled: a response lost in transit also loses the successor code. That is addressed by the persistent-connection design in #40 and discussed in #54.

Verification. cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test are clean (100 passed, 24 ignored). Two new DB tests cover a code idle for a day (still redeemable, still single-use) and a code idle past 30 days (deleted). Like the existing DB tests they are #[ignore]d locally and run in CI with --include-ignored. The #40 branch, stacked on this commit, ran the full suite against Postgres. Not tested against a live provider.

🤖 Generated with Claude Code

@michielbdejong
michielbdejong added this pull request to the merge queue Sep 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 23, 2026
…0 minutes

A connection_codes row is the only server-side copy of the sealed
StoredCredential, including the OAuth refresh token. Codes were stored
with a ten-minute expiry and swept on every insert, so a client that
stopped syncing for ten minutes lost the grant and had to re-OAuth.

Store codes with a CONNECTION_CODE_IDLE_DAYS (30-day) lifetime instead.
Codes stay single-use and are rotated on every proxied request, so this
is an idle timeout measured from last use; abandoned grants are still
swept. Handoff codes (5 min), OAuth states and nonces (10 min) are
unchanged. No schema or client change. Rows already in flight get the
new lifetime on their next rotation.

Adds PostgreSQL tests, #[ignore]d like the existing DB tests: a code
idle for a day is still redeemable, and a code idle past the lifetime
is swept. SECURITY.md now describes the new lifetime and its
trade-off: a leaked, unused code stays valid for longer.

The persistent connections table proposed in #42, and the lost-response
case, are left to #40.

Fixes #42

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michielbdejong
michielbdejong force-pushed the claude/issue-42-connection-code-idle-ttl branch from 314ee21 to 075c9fb Compare September 23, 2026 09:17
@michielbdejong
michielbdejong merged commit 10c60eb into main Sep 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

integration-proxy: a refresh token is destroyed after ten idle minutes

1 participant