Repository navigation
GitHub connector: support refresh tokens (cherry-pick dexidp/dex#4845) - #76
Conversation
Cherry-pick of upstream dexidp#4845 (e8aaa98), which is merged to upstream master but not yet in any release (latest release v2.45.1 is from before the merge). Adapts the new test's single HandleCallback call site from the 3-arg signature (introduced upstream by PKCE PR dexidp#3777, not present in this fork) back to the 2-arg signature on this branch. Production code applies unchanged. Fixes forced re-login after ~8h for GitHub App-backed connectors. Signed-off-by: Matheus Pimenta <[email protected]> (cherry picked from commit e8aaa98) Closes: giantswarm/giantswarm#37164
Code review (automated, high-effort recall)Clean cherry-pick of upstream dexidp#4845. No high-severity logic bug in the happy path — the refresh mechanism is correct and well-tested. Findings are low-severity; merging. 1. (medium/robustness) Rotated refresh token can be lost on a transient
|
Follow-up: test coverage gap on the group-backed refresh pathBoth new refresh tests ( A test that configures Not blocking — the cherry-pick is clean and this doesn't touch production code, so it's fine to merge the hotfix and add this test as a follow-up. Generated by Claude Code |
puja108
left a comment
There was a problem hiding this comment.
LGTM, clean cherry pick once the issues your own review mentioned and CI is fixed
What
Cherry-picks upstream dexidp/dex#4845 (
e8aaa98b, "GitHub Connector: Implement support for refresh tokens") onto this fork.The GitHub connector now persists GitHub's refresh token + expiry in
connectorDataand renews the upstream user access token duringRefresh(), instead of rebuilding the oauth2 client with only the originally-stored access token (which could never renew).Why
Fixes giantswarm/giantswarm#37164 — muster (and any long-lived
giantswarm-github-backed session) is force-logged-out after ~8h, well under the intended 30-day (720h) refresh-token lifetime.Root cause: the
giantswarm-githubconnector is backed by a GitHub App, whose user-to-server tokens expire after exactly 8 hours. On dex refresh the old connector could not renew the upstream token, so at login+8h GitHub returned401 Bad credentials, dex's refresh failed, and the session died. Azure (giantswarm-ad) was unaffected because its connector already refreshes upstream tokens.Why cherry-pick and not a full upgrade
master(2026-07-02) but in no release yet — latest releasev2.45.1predates it, so upgrading to any tagged version would not fix this.masteris ~649 commits / ~53k insertions across 321 files, and this fork carries custom patches (group-prefixing inserver/handlers.go/refreshhandlers.go/server.go, OIDC rootCA fix) in files upstream churned heavily — high risk, no extra benefit for this issue.connector/github/github.goapplies with zero conflicts (the fork's github connector was identical to upstream v2.43.1), builds, and the connector test suite passes.Note on the test adaptation
The upstream fix's test added one
HandleCallbackcall using the 3-arg signature(scopes, connData, req)introduced by an unrelated upstream PKCE PR (dexidp#3777) that is not in this fork. That single call site is adapted back to this fork's 2-arg signature. Production code is unchanged from upstream.Rollout note
Existing sessions only benefit after each user logs in once post-rollout — older
connectorDatahas no upstream refresh token stored. After that, GitHub-backed sessions are bounded by dex policy (720h), since GitHub App refresh tokens last ~6 months.Test plan
go build ./...go test ./connector/github/— passesv2.43.1-gs5, bump dex-app, roll out to MCs (follow-up)Refs giantswarm/giantswarm#37164