Skip to content

🔑 feat: Let Users Connect Their Own Account for Pull Request Lookups - #16989

Merged
berry-13 merged 37 commits into
devfrom
berry-13/pr-user-oauth
Oct 12, 2026
Merged

berry-13 merged 37 commits into
devfrom
berry-13/pr-user-oauth

Conversation

@berry-13

@berry-13 berry-13 commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

Every lookup runs on one server token, so the deployment shares a single provider rate limit and an operator has to list the repositories that token may read. With pullRequests.oauth (client ID and secret as environment references) users can connect their own GitHub, GitLab or Bitbucket account; their lookups then run on their own token, rate limit and repository access, and the server token stays as the fallback for users who have not connected. A user's own token is not held to allowedRepositories, because it can only see what that user can already see.

Four routes under /api/pull-requests/oauth connect, receive the callback, report status and disconnect. The state is a short-lived signed token, the PKCE verifier is derived from it with the server secret so it never reaches the browser, and the callback must come back to the browser that started the flow (the existing OAuth CSRF or session cookie) and restores the tenant from the state. Grants are stored encrypted, one row per user and provider host, and every write is a compare-and-swap on the exact stored version: one replica at a time refreshes (a lease), only a definite refusal disconnects, an outage answers unavailable rather than falling back to the server token, and a disconnect or account deletion fences flows and reads that started before it. A connection belongs to the app it was made with: changing clientId, provider or host asks users to connect again, and a changed scope applies to new connections only. Retention counts from last use under the current retentionDays. Like host and provider, oauth is read from the operator's YAML only. The setting to connect is the next PR.

Part of a stack on #16982, merge from the bottom up: host (1), GitLab (2), Bitbucket (3), shared cache (4), user OAuth backend (5), connected account setting (6). Each PR is based on the one below it, so its diff is only its own link.

Type of change

  • Feature

Testing

Tested environments/configuration:

  • Local backend with a test OAuth app in a local YAML copy: /api/config advertised pullRequestsConnect, status reported not connected, connect returned the GitHub authorize URL with the right callback, and the callback refused both a forged state and a valid state from a browser without the flow cookie (invalid_state). A full round trip with a real OAuth app was not run.

Automated tests:

  • packages/api: npx jest src/pulls src/admin src/oauth passes (1471 tests, src/pulls five times in a row); oauth.spec.ts runs against MongoDB Memory Server and covers the PKCE pair, encrypted storage, refusal versus outage, the refresh lease and cross-replica races, retention from last use, disconnect and deletion fences, and a replaced app. connect.spec.ts covers every callback failure, the flow named on the landing page, and the limiter. Each fix was mutation-checked.
  • Config spec, typechecks, the packages/api build and the convos route specs pass.

Screenshots / recordings

No user-facing change

Risk / compatibility

Security-sensitive: new unauthenticated callback route, protected by the signed state plus the CSRF or session cookie. Disconnect, and admin or self-service account deletion, delete the stored grants but do not revoke them at the provider. Without oauth, behavior is unchanged.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors
  • User-facing or complex behavior is documented where necessary
  • Required dependency changes have been merged/published
  • Required documentation PR: N/A until the stack is approved; the new pullRequests fields are documented in librechat.example.yaml

@berry-13
berry-13 added this pull request to stack #16991 October 11, 2026 17:22
Copilot AI balanced review requested due to automatic review settings October 11, 2026 17:35
@berry-13
berry-13 force-pushed the berry-13/pr-user-oauth branch from a1989d0 to 595699a Compare October 11, 2026 17:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@berry-13
berry-13 marked this pull request as ready for review October 11, 2026 17:45
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T13:18:02.204890Z b270a66 New commits
🔒 Security Review ✅ Completed 2026-10-11T17:53:17.437933Z 595699a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 595699a563

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread api/server/routes/pullRequests.js Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/capabilities.ts
Comment thread packages/api/src/pulls/capabilities.ts
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread api/server/index.js Outdated
Comment thread api/server/index.js Outdated
Comment thread packages/api/src/pulls/connect.ts Outdated
@berry-13
berry-13 force-pushed the berry-13/pr-user-oauth branch 3 times, most recently from 283357e to 7d04176 Compare October 11, 2026 21:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d04176544

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/handler.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
@berry-13
berry-13 force-pushed the berry-13/pr-user-oauth branch from 7d04176 to e4fce37 Compare October 11, 2026 22:08

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4fce379d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
@berry-13
berry-13 force-pushed the berry-13/pr-user-oauth branch from e4fce37 to 88e816d Compare October 11, 2026 22:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88e816d818

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/connect.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/handler.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/connect.ts Outdated
@berry-13
berry-13 force-pushed the berry-13/pr-user-oauth branch from 88e816d to b04f346 Compare October 11, 2026 23:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b04f3468a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/connect.ts
Comment thread packages/api/src/pulls/handler.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45ac3c4e35

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/handler.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c39693f8d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/oauth.ts
Comment thread packages/api/src/pulls/oauth.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 540c4ece30

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/connect.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88f3ea640c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/connect.ts
Comment thread packages/api/src/pulls/oauth.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d1ae638724

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts
Comment thread packages/api/src/pulls/oauth.ts Outdated
@berry-13
berry-13 force-pushed the berry-13/pr-user-oauth branch 2 times, most recently from c643b80 to 9d064db Compare October 12, 2026 05:35
Base automatically changed from berry-13/pr-shared-cache to dev October 12, 2026 05:35
@berry-13
berry-13 force-pushed the berry-13/pr-user-oauth branch from 9d064db to 682921d Compare October 12, 2026 05:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 682921d0f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/capabilities.ts
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
@berry-13
berry-13 force-pushed the berry-13/pr-user-oauth branch from 9d471a3 to 1ed8ace Compare October 12, 2026 12:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ed8ace871

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/capabilities.ts
Comment thread packages/api/src/pulls/oauth.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdebfd5300

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/capabilities.ts
Comment thread packages/api/src/pulls/oauth.ts Outdated
Comment thread packages/api/src/pulls/handler.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce13b8501a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread packages/api/src/pulls/handler.ts Outdated
Comment thread packages/api/src/pulls/oauth.ts Outdated
@berry-13
berry-13 merged commit 0bc344f into dev Oct 12, 2026
46 checks passed
@berry-13
berry-13 deleted the berry-13/pr-user-oauth branch October 12, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants