Skip to content

Add per-user allowlists for chat provider endpoints - #17177

Open
cidrblock wants to merge 1 commit into
LibreChat-AI:devfrom
cidrblock:feat/user-endpoint-access
Open

cidrblock wants to merge 1 commit into
LibreChat-AI:devfrom
cidrblock:feat/user-endpoint-access

Conversation

@cidrblock

Copy link
Copy Markdown

Summary

  • Add optional endpoints.userAccess rules mapping a username to exact allowed provider endpoint names. Matching is case-insensitive; endpoint names use LibreChat normalization.
  • Filter the authenticated endpoint/model catalogs and model specs, and reject disallowed normal chat requests server-side before provider construction.
  • Keep this policy at deployment scope so user config overrides and tombstones cannot widen access. With no matching rule, behavior remains unrestricted; an explicit empty list denies all provider endpoints for that user.

Verification

  • API endpoint/userAccess suites: 61 tests passed.
  • Legacy API model/controller/config/middleware suites: 109 tests passed.
  • Config override resolution suite: 85 tests passed.
  • Data-provider config schema suite: passed.

Fixtures use generic user and endpoint names. This PR is separate from MCP App tool approval.

Copilot AI balanced review requested due to automatic review settings October 15, 2026 20:06

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.

🟡 Changes recommended

Configuration loading drops the policy, model filtering breaks agents-only deployments, and case-folding conflates distinct provider identities.

3 open findings
What changed in this PR

Adds deployment-controlled per-user endpoint allowlists to restrict provider visibility and normal chat requests.

Changes:

  • Defines allowlist configuration and protects it from principal overrides.
  • Adds endpoint, model catalog, and model-spec filtering.
  • Adds chat authorization guards and regression tests.
File Description
packages/​data-schemas/​src/​types/​app.ts Adds runtime policy typing.
packages/​data-schemas/​src/​app/​resolution.spec.ts Tests deployment-only policy ownership.
packages/​data-provider/​src/​config.ts Defines and protects allowlist configuration.
packages/​data-provider/​src/​config.spec.ts Tests policy validation.
packages/​api/​src/​endpoints/​config/​userAccess.ts Implements access and filtering helpers.
packages/​api/​src/​endpoints/​config/​userAccess.spec.ts Tests policy matching and filtering.
packages/​api/​src/​endpoints/​config/​index.ts Exports policy helpers.
packages/​api/​src/​endpoints/​config/​endpoints.ts Filters endpoint catalogs.
packages/​api/​src/​endpoints/​config/​endpoints.spec.ts Tests user-scoped endpoint visibility.
api/​server/​routes/​config.js Filters returned model specs.
api/​server/​routes/​__tests__/​config.spec.js Tests model-spec visibility.
api/​server/​middleware/​validateModel.js Adds endpoint authorization.
api/​server/​middleware/​buildEndpointOption.js Guards provider request construction.
api/​server/​middleware/​__tests__/​validateModel.spec.js Tests unauthorized endpoint rejection.
api/​server/​middleware/​__tests__/​buildEndpointOption.userAccess.spec.js Tests early request rejection.
api/​server/​controllers/​ModelController.spec.js Tests model catalog filtering.
api/​server/​controllers/​ModelController.js Filters model catalogs through endpoint visibility.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/api/src/endpoints/config/endpoints.ts
Comment thread packages/api/src/endpoints/config/userAccess.ts Outdated
Comment thread api/server/controllers/ModelController.js Outdated
@cidrblock
cidrblock force-pushed the feat/user-endpoint-access branch from 46e2dc8 to bebc7e4 Compare October 15, 2026 20:39
@cidrblock
cidrblock force-pushed the feat/user-endpoint-access branch from bebc7e4 to cf9537d Compare October 15, 2026 20:53

This branch has not been deployed

No deployments
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.

2 participants