Repository navigation
integration-proxy: keep connection codes for 30 idle days, not 10 minutes (#42) - #61
Merged
Merged
Conversation
michielbdejong
added this pull request to the merge queue
Sep 23, 2026
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
force-pushed
the
claude/issue-42-connection-code-idle-ttl
branch
from
September 23, 2026 09:17
314ee21 to
075c9fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
pub const CONNECTION_CODE_IDLE_DAYS: i32 = 30. Connection codes are now stored withNOW() + make_interval(days => $3).SECURITY.mdstates 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 warningsandcargo testare 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