mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
* 🔐 feat: Admin Config Secrets v2 (MCP and Azure Credentials, Re-entry, Env Allowlist, Rebinding) The admin config API stored MCP server credentials and Azure group keys in plaintext, returned them to config readers, let an admin who cannot read a stored credential send it to a host of their choosing, and let override values reference any environment variable. MCP credentials and Azure keys, in `groups` and in the `groupMap` the Azure clients read, are now encrypted with masked previews, hidden from every read and decrypted once after the merge. A write that keeps a stored MCP credential or web search key while changing where it is sent must enter it again, judged by the value the written document holds. `${VAR}` references in overrides are limited to an allowlist, named where a change batch leaves them, and the merge drops a credential a layer moves to a new destination without entering it, listing it in write responses only for sections the caller can read. A custom endpoint's key is bound to its base URL, its provider and the destination options in addParams and dropParams (such as the anthropicApiUrl the native Anthropic client sends to), matched across layers under the name the merge folds (ollama is Ollama). A restated `${VAR}` counts as entered, so allowlisted names are not bound to a destination. Azure's `${INSTANCE_NAME}` and `${DEPLOYMENT_NAME}` stay templates in a group's `baseURL`, and a scheduled job's MCP consent no longer depends on the masked previews that change when an admin rotates the key in place. * ♻️ refactor: Move the MCP Key Re-entry Guard Out of the Binding Helpers to Break an Import Cycle With #17351's OpenID provisioning on dev, the app config service reached itself through the rebinding guard: app/service -> app/overrides -> app/rebinding -> mcp/registry/binding -> mcp/errors (and mcp/types) -> mcp/oauth/obo -> utils/identity -> auth/openid -> auth/provision -> app/resolve -> app/service. The binding helpers are pure diffs; only requireApiKeyReentryForRebinding needs the MCP error class, so it moves to mcp/registry/reentry.ts, and the helpers take MCPOptions from librechat-data-provider as mcp/headers.ts does. No behaviour changes. * 🧪 test: Drop a Base-Held Endpoint Key That a Lower-Priority Profile Moves Base merges first since #17352, so a profile below Base's priority still lands over it. The rebinding guard drops the key Base stores for a custom endpoint whose baseURL the profile changes, and the PATCH response lists it in `ignored`. * 🔐 fix: Serve Admin Azure Group Keys and Keep Deployment Keys at Their Own Destinations Azure groups a profile writes now take effect: the merge resolves a layer's `endpoints.azureOpenAI.groups` as AppService resolves librechat.yaml's (`resolveAzureGroups`, shared with `azureConfigSetup`) into the `groupMap`, `modelGroupMap`, model list and assistant models the Azure clients read. A layer's groups replace the groups below whole, as its array does; groups that do not resolve stay unread with a warning. The rebinding guard judges the resolved groups like any `groupMap` entry, and an Azure group's destination now also covers a deployment name its base URL takes its host from and the destination options of its `addParams`/`dropParams`. A write that keeps a stored Azure group key (in `groups` or `groupMap`) while changing where the group sends it answers 400 `CONFIG_SECRET_REENTRY_REQUIRED` on PUT, PATCH, field deletes, tombstones and change batches, judged as the document resolves over librechat.yaml and on each `groups` item as written. OCR fills an empty key from `OCR_API_KEY` only for its default destination (no base URL, or `${OCR_BASEURL}`), so a key the guard dropped for an override's `${VAR}` base URL is not replaced by the deployment's. The env reference policy includes the `${OCR_API_KEY}` loading fills in for an `ocr` section without a key, so a client can write back what GET `/base` returned. The custom endpoint guard no longer needs the layer's overrides to name an entry: an entry changed some other way is judged as inherited (positional tombstones inside the list are not applied by the merge, so none reached one). A web search URL a layer points at a `${VAR}` other than librechat.yaml's without entering its key is set back: web search sends the deployment's key, or its client's environment default, to any `${VAR}` URL. * 🔐 fix: Keep Azure Assistants Served, Opaque Keys as Entered and Batch Env Checks on the End State Azure assistants: a profile's `groups` replace the groups below whole, so groups with no model that supports assistants under librechat.yaml's `assistants: true` left `assistants` on with an empty `assistantModels`, and the Azure Assistants initializer picked `assistantModels[0]` (undefined). `azureConfigSetup` refuses that combination at startup; the merge now turns `assistants` off when none of the models it leaves supports them, with a warning, judged on the merged result so a later layer whose groups serve assistants keeps them on. The check is `lacksAzureAssistantModels`, shared with `azureConfigSetup`. Opaque credentials: every runtime reader of the OCR, speech, web search and Langfuse keys uses the decrypted value as is (`resolveConfigSecret`, `resolveStoredConfigSecret`, `decryptConfigSecret`), so a `${...}` inside a key the write encrypts is part of the key. Those fields are marked `opaque`: the write-time check skips a value the write encrypts there, and the runtime pass keeps their ciphertext instead of blanking it. A whole `${VAR}` reference there, which the field passes through and its reader resolves, is still checked, and so is stored plaintext. Custom endpoint (`initializeCustom`), Azure group (`mapModelToAzureConfig`) and MCP (`processMCPEnv`) credentials are expanded by their clients once decrypted and stay checked; the Assistants keys have no reader yet and stay checked too. Change batches: env references are judged on the document the batch leaves, as its other issues are. An issue counts only when the end state still holds a disallowed reference (ciphertext by its plaintext) where the batch sent one, at a location the batch changed, so a value a later op removes or replaces (`set ocr.baseURL`, then `unset ocr`) is no longer refused, and a stored reference the batch puts back where it was is left to merge time. * 🔐 fix: Proxy-Bound OAuth Secrets, Consistent Azure Group State, Batch Issues by Entry Key and Loaded Web Search References - The MCP proxy is part of the OAuth client secret's binding (user tier, admin re-entry and the merge's rebinding guard share `getChangedOAuthSecretBindingFields`): the access token the secret obtains travels through it. - A tombstone of `endpoints.azureOpenAI.groups` resolves the groups to none in the merge (empty `groupMap`, `modelGroupMap` and model lists, so the model list does not fall back to the environment's defaults), and removes what they resolve to in `applyConfigTombstones`. - The merged Azure model lists name only models a merged group serves (`narrowAzureServedModels`), so an override's `assistantModels` no group serves no longer keeps Azure assistants on. - `/changes` env issues are held by entry identity (`toConfigIdentityPath`), followed through renames and resolved on the batch's end state, so a removal or rename no longer shifts them. - References loading librechat.yaml introduces (OCR's `${OCR_API_KEY}`, the web search defaults) are allowed at the location they are loaded at, so GET /base's sections are accepted written back, and nowhere else. * 🔐 fix: Re-entry for Endpoint, OCR and Speech Keys, Own Keys Bound Over Base and User Key Destinations Kept - The document that stores a custom endpoint, OCR or speech key can no longer move its destination without the key: PUT, PATCH, field deletes, tombstones and change batches answer CONFIG_SECRET_REENTRY_REQUIRED at the changed field (getBoundKeyReentryIssues), judged by value as the document alone sends it. - A profile's own key for an endpoint, MCP server, OCR or speech service, or Azure groupMap group that Base defines is bound to that destination when it is entered: the rebinding guard reports a fingerprint of where it goes, the write stores it beside the key (<secret>Binding), and the guard keeps the key there until a lower layer moves it. Reads and the merged config leave the fingerprint out; kept keys carry it; client values are replaced. - An inherited custom endpoint or MCP server that sends a credential each user holds (user_provided, customUserVars, apiKey.source user, OpenID or Graph token placeholders) keeps its destination: a layer's move is set back and listed in ignored. |
||
|---|---|---|
| .. | ||
| app/clients | ||
| cache | ||
| config | ||
| db | ||
| models | ||
| server | ||
| strategies | ||
| test | ||
| utils | ||
| jest.config.js | ||
| jsconfig.json | ||
| package.json | ||
| recover-skill-upload.js | ||
| typedefs.js | ||