🤝 fix: Honor OPENID_REUSE_TOKENS in Admin OAuth Exchange#13154
Merged
danny-avila merged 1 commit intoMay 18, 2026
Merged
Conversation
Owner
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danny-avila
approved these changes
May 18, 2026
patricia2510
pushed a commit
to lexaeon-org/libre-chat
that referenced
this pull request
May 21, 2026
fuuuzzy
pushed a commit
to fuuuzzy/LibreChat
that referenced
this pull request
May 22, 2026
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
Closes #13033 — honor
OPENID_REUSE_TOKENSin the admin OAuth exchange path.The
/api/admin/oauth/refreshendpoint already enforces this flag (returns403 TOKEN_REUSE_DISABLEDwhen disabled, added in #13007). However, the upstream/api/admin/oauth/exchangepath inapi/server/controllers/auth/oauth.jsunconditionally extracted and forwarded the IdPrefreshTokeninto the exchange payload, regardless of theOPENID_REUSE_TOKENSsetting. This left a sensitive IdP refresh token stored in the admin-panel BFF session even when the operator had explicitly disabled token reuse — a policy inconsistency and unnecessary token exposure.Fix: gate the
refreshTokenextraction in the admin-panel redirect branch onreq.user.provider === 'openid' && isEnabled(process.env.OPENID_REUSE_TOKENS) === true, mirroring the logic already applied in the standard (non-admin) OAuth path and the refresh endpoint.Changed files:
api/server/controllers/auth/oauth.jsOPENID_REUSE_TOKENSflagapi/server/controllers/auth/oauth.spec.jsChange Type
Testing
Test Configuration
OPENID_REUSE_TOKENSfalse(disabled branch),true(enabled branch)New Unit Tests
api/server/controllers/auth/oauth.spec.js— added two focused unit tests for the admin-panel redirect path:OPENID_REUSE_TOKENSdisabled — asserts thatgenerateAdminExchangeCodereceivesundefinedas the refresh-token argument, so the exchange payload never contains an IdP token.OPENID_REUSE_TOKENSenabled — asserts thatgenerateAdminExchangeCodereceives the OpenIDrefresh_token, preserving the existing enabled-path behavior.Run the new controller tests:
Result:
Run together with the related admin refresh regression suite:
npm --prefix api run test:ci -- \ --runTestsByPath api/server/controllers/auth/oauth.spec.js \ api/server/routes/admin/auth.refresh.test.jsResult:
Checklist