feat(hub): OAuth tokens refresh ahead of expiry and Settings offers sign-in again (CL-8592) - #945
Merged
Merged
Conversation
…ign-in again (CL-8592)
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.
Summary
A Codex or xAI credential minted by signing in carries an access token that lapses in under an hour. Stock Interchange has no serving-time refresh hook, so the token simply fails the next inference call. The hub now renews these credentials on a timer, ahead of expiry, and pushes the fresh material to running sidecars. Settings → Credentials offers "Sign in again" for the case a refresh can no longer save.
Design
@corbits/oauth-core's hub export gainscreateOAuthTokenRefresher. Each tick claims dueoauth_tokenrows (FOR UPDATE SKIP LOCKED, due-ness re-checked under the lock, so two hubs never double-refresh), calls the provider'srefresh, and writes the new material through the same path the login flow uses.oauthProvider) at persist time; the stockproviderrow is host-named and per-tenant, so it cannot identify a registry entry.onRefreshedfires the stockpushSourceUpdatesexactly as the stock credentials route does after a secret rotation, so running sidecars get the rotated secret.reportError.startProviderLogin/readProviderLogin) throughuseMutation/useQuery; re-signing in files the tokens under the same credential name, so offerings keep pointing at the same row.Credentials written before this change carry no
oauthProvidermetadata and are not refreshed; "Sign in again" files them correctly.Changes
apps/hub/package.json: pin@corbits/oauth-coreto the refresher. This is the library branch head (f818dcb) until Refresh OAuth tokens ahead of expiry corbits-oauth-core#7 merges; it moves to the merged sha then.apps/hub/src/server.ts:refreshon both providers, the refresher started in the Corbits block,pushSourceUpdatesfromonRefreshed.apps/web/src/settings: "Sign in again" on anoauth_tokenrow, plus its strings.Testing
bun run checkgreen. The refresh decisions themselves are covered by unit tests in the library PR.