Skip to content

feat(router): re-fetch the cached OAuth token when the control plane holds a newer secret - #7492

Closed
atzoum wants to merge 1 commit into
masterfrom
spike/oauth-secret-version-hybrid
Closed

atzoum wants to merge 1 commit into
masterfrom
spike/oauth-secret-version-hybrid

Conversation

@atzoum

@atzoum atzoum commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Description

Alternative to #7478 without package-level state. The OAuth handler re-fetches a cached token when the account's secretVersion is strictly newer than the token's. Router and regulation-worker requests carry the version on their destination's account (OAuthTokenParams.SecretVersion). Async destinations keep the destination their manager was built with until its revision changes, which a re-authorization doesn't do, so the batch router fills a SecretVersionProvider from its existing config loop and hands it to their handlers through asyncManagerFactory.

Linear Ticket

n/a

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

🤖 Generated with Claude Code

…holds a newer secret

Router and transport callers pass the account's secretVersion from the request's destination; the
batch router keeps its destinations' versions from its config loop and hands them to the OAuth
handlers of async destinations, whose destination snapshot only changes with the revision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.30.1
@atzoum atzoum closed this Oct 20, 2026
@atzoum atzoum mentioned this pull request Oct 20, 2026
1 task done
tipped73 added a commit that referenced this pull request Oct 20, 2026
…holds a newer secret (PRO-5947) (#7478)

# Description

When a customer re-authorizes a destination, config-backend stores a new
secret and bumps the account's `secretVersion`, but a pod keeps using
the token it cached until it expires or a delivery fails with the
refresh-token class. The inactive (403) class never re-asks (INT-6859;
spec rudderlabs/rudder-specs#193, LLD 3.9).

The handler now re-fetches a cached token when the control plane's
version for the account is strictly newer than the token's own, which it
parses from the token response. A token with version 0 is never
superseded, and the re-fetch is a plain fetch, not a forced refresh.

How the version reaches the handler, with no new goroutine and no
process-wide state. This is the design from #7492, cherry-picked here as
its author's commit; the second commit only adds tests and doc lines:

- Router and regulation worker: every job carries a fresh destination
from their own config loop, with the account attached, so the transport
copies `GetSecretVersion(flow)` into the token params.
- Batch router: its async managers keep their destination until the
revision changes, which a re-authorization does not do. So the batch
router fills an account-to-version map inside its existing config loop
and hands it to them as a `SecretVersionProvider`. The map is filled
from the delivery account config-backend attaches to each async
destination.
- Handler: compares the cached version against the larger of the two.

Tests: `GetSecretVersion`; the transport passing the version for both
flows; the batch router provider; the handler suite (fetch once then
serve from cache for the router param, the provider, a stale snapshot
and a caller newer than the provider; cached when same version, older
config, version 0 or no version; cold cache keeps the response's
version); and the response parsing. Build, vet, golangci-lint and `go
test -race ./services/oauth/...` are green. On mini, bumping the
account's version while the pod held its token made the branch log the
superseded token and fetch once; the stock image kept the old token.

Related: #7477 touches the same handler file; no conflicts today.

## Linear Ticket


https://linear.app/rudderstack/issue/PRO-5947/rudder-server-re-fetch-the-cached-oauth-token-when-the-control-plane

## Security

- [x] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.

---------

Co-authored-by: Aris Tzoumas <[email protected]>
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.

1 participant