mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 14:08:21 +00:00
5 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4d061fdd46
|
🔄 fix: Judge Tenant Profiles on Their Own Base, Clear Config Caches on Principal Deletion, and Add a Config Reload Route (#17397)
Profile writes are judged in the tenant partition the profile merges in. For a role, or a
caller inside a tenant, that is the caller's partition. For a group or user profile written by
an admin without a tenant, it is the stored document's tenant: PUT, PATCH and POST …/changes
validate on librechat.yaml as that tenant resolves it with that tenant's __base__ over it, use
the same Base for the recheck after commit and for key binding, tombstones and field deletes
judge re-entry on that tenant's librechat.yaml, and every route reports `ignored` over that
tenant's Base. Each attempt reads the document in that partition only, and a document that
moved partition while the write ran answers 409 CONFIG_VERSION_CONFLICT. The config store's
partition rules are unchanged; another tenant's Base is read in that tenant's context.
Deleting a group, role or user clears the config caches when it removes or restores the
principal's profile (`invalidatingConfigStore`), awaited before the response and broadcast with
Redis as config writes do; a call that rejects clears too, since it may have committed.
POST …/changes lets `unset` remove any part of a top-level section configSchema does not
define; the section's own `unknown_section` issue is no longer blamed on the removal, and every
other op there still answers 400 UNKNOWN_SECTION.
POST /api/admin/config/reload, for an admin without a tenant holding broad manage:configs (a
tenant admin gets 403, since the reload reaches every tenant), runs the config cache clear without
a write, loads librechat.yaml again on the answering instance, and once it loaded publishes the
clear over Redis so every other instance loads the file on its next read. It uses
ConfigCacheInvalidation.reload, which reports the clear, the load and the publish instead of only
logging a failure (writes keep `invalidate`, which leaves the load to the next read). It answers
200 `{ success: true, broadcast }`, `broadcast` false without Redis; 422 CONFIG_RELOAD_INVALID
with each schema issue's location when the loader refuses the file, keeping the last good config
and publishing nothing; 500 CONFIG_RELOAD_FAILED when a clear fails or the config cannot be built
from the file; and 503 CONFIG_RELOAD_BROADCAST_FAILED when this instance reloaded but the publish
failed, since an instance that misses the broadcast keeps its cached librechat.yaml, which never
expires. Every reload that runs is audited as `config.reloaded`, a failed one with outcome
`failure` and its code. The meta reports `features.reloadRoute`. Writes still reload the file.
The e2e content-filter helper uses the route instead of a sentinel profile.
docs/mcp-overrides.md describes the current timing: the awaited clear, the Redis broadcast, what
still waits for a TTL, that a process the clear misses keeps its old librechat.yaml, and hiding
as an access boundary at checkout.
|
||
|
|
9adabde72e
|
🗂️ feat: Audit MCP, Code Worker, Langfuse, Skill Credential, Passkey and Audit Log Access (#17054)
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
* fix: Remove Group Dependents Before Deleting the Group * feat: Audit Code Worker Pairing and Langfuse Connection Changes * feat: Audit Skill Sync Credential Changes * feat: Audit Passkey Enrolment and Removal * feat: Audit Audit Log Reads and CSV Exports * feat: Audit Audit Log Retention Purges * feat: Audit MCP Server Create, Update and Delete * fix: Keep Purge Result When the Purge Audit Write Fails * test: Cover Admin Integration Audit Scenarios * fix: Tighten Admin Integration Audit Scope and Group Cleanup Order * fix: Run Security Fences Before Awaiting Audit Writes * fix: Move MCP Post-Commit Audit Ordering Into the Auditor and Audit Verify Reads * fix: Fail Closed When Recording Audit Log Access * fix: Audit Group Deletion Before the Cascade and Restore Dependents on Failure * fix: Restore Only Config Overrides When Group Deletion Fails * fix: Audit Worker Pairing and Export Before the Work and Append Failures * fix: Record Group Deletion as Pending Without Delaying Revocation * fix: Skip Config Restore When a Concurrent Delete Removed the Group * fix: Restore Group Config When the Existence Recheck Fails * fix: Keep Group Config Restricted When Delete State Is Unknown * fix: Record Worker Pairing and Revocation as Pending Until Confirmed * fix: Deliver the Pairing Code Before the Terminal Audit Write * test: Assert Pairing Code Delivery Precedes the Terminal Audit Write * fix: Send Revocation and Group Deletion Responses Before the Terminal Audit Write * fix: Snapshot Group Config Before the Destructive Cascade Step * refactor: Type the Group Config Snapshot Dependency Without Mongoose Shapes * fix: Fence Shared MCP Users Before the Deletion Audit and Correlate Audit Attempts * fix: Diff MCP Server Audits Against the Committed Config * fix: Read the Committed MCP Config at Commit Time for the Audit Diff * refactor: Start the Committed MCP Config Read Inside the Auditor * fix: Audit Langfuse Patches When Activation Fails and Surface Failed Group Config Restores * fix: Record Member Removals When Group Deletion Completes After a Failed Restore * test: Serve the Committed Config on the MCP Update Audit Reread * fix: Audit the Group Returned by the Compensating Deletion * fix: Keep Member Removal Audits Fail-Open During Group Deletion * fix: Retry ACL Cleanup After a Compensating Group Deletion * fix: Mark Unavailable Audit Detail and Order Member Removals After the Pending Deletion * fix: Guard Synchronous Committed-Config Read Failures in the MCP Auditor * fix: Return the Persisted MCP Config and Audit Commits That Outlive Cache Invalidation * style: Sort Imports in MCP Audit Files * style: Sort Imports After Restack * fix: Audit MCP Commits That Outlive Any Post-Write Step and Pend Audit Exports Until Complete * test: Provide the Fail-Closed Setting in the Code Route Mock * fix: Refresh MCP Read Caches When a Repository Step Fails After the Write * fix: Finish Audit Exports on Response Completion and Keep Error Details Out of Messages and Logs * fix: Watch Response Completion Before the Truncation Footer Write * fix: Skip Audit for No-op MCP Deletes and Close Remaining Post-Failure Audit Gaps * fix: Keep Causes Out of Structured Logs and Treat a Lost Compensating Delete as Not Found * fix: Mark Failed MCP Post-Commit Steps and Null Langfuse Activation in Audits |
||
|
|
ccae5b988d
|
📜 feat: Audit Admin Role, Group, Config and IdP Role Mutations (#17052)
* feat: Extend the Audit Action Vocabulary to Admin, Sync and Credential Mutations * feat: Audit Admin Role, Group and Config Mutations Role deletion now removes the role's grants, ACL entries and config overrides before the role itself and returns ROLE_CLEANUP_FAILED instead of success when any of them fails, so a recreated role cannot inherit leftover privileges. * feat: Audit IdP and Startup Role Changes * fix: Keep the Startup Role Sync Running When Its Audit Verification Read Fails * test: Cover Admin Role Audit Trail End to End * fix: Audit a Remote Agent Role Sync Only After It Persists * fix: Restore Role Dependents When Role Deletion Fails Midway * fix: Restore Role Dependents Only When the Role Still Exists * style: Sort Role Admin Imports * fix: Keep the ACL Snapshot When Role Cleanup Fails Ambiguously * test: Read Role Audit Entries From the Audit Log Route * fix: Audit Only Real Membership Changes and Restore Deleted Role Config in Full * fix: Restore Deleted Role Grants in Full and Sanitize Audit Write Logging * fix: Audit and Report a Role Deletion Confirmed After a Lost Response * fix: Never Restore Dependents Onto a Recreated Role * fix: Snapshot Role Dependents Before Deleting and Detect Membership Changes Atomically * fix: Restore From the Data a Cascade Step Actually Removed * fix: Restore Only Config Overrides When a Role Delete Fails * fix: Log Only Safe Metadata When the Startup Audit Read Fails * fix: Audit Grants Removed by a Failed Role Delete * fix: Audit Removed Grants on Unverifiable Role Delete Exits * fix: Honor Fail-Closed Auditing in the Admin Config, Group and Role Routes * fix: Bind Role Deletion to the Captured Id and Audit Only Atomic Role and Config Changes * fix: Skip the Config Restore When the Targeted Role Is Gone * fix: Audit Initial Group Members and Skip No-Op Role Description Updates * fix: Record Role Deletion as Pending Before Cleanup and Append Its Outcome * fix: Audit Reassigned Role Members and Return the Persisted Config After a Tracked Toggle * fix: Keep a Committed Role Deletion Successful When Cascade Audit Writes Fail * fix: Decide Group Update Audits From the Atomic Write and Sanitize Permission Update Logs * fix: Audit Grants From a Snapshot, Fail on Member Lookup Errors and Chunk Member Audit Entries * fix: Audit Group Deletion Members and Previous Role Removal, Abort on Grant Snapshot Failure * fix: Invalidate Config Caches After Partial Secret Writes * fix: Retry Failed Cascade Restores, Report Changed Group Fields and Audit Every Reassigned Member * fix: Log Safe Metadata When Cache Invalidation Fails After a Partial Write * fix: Keep Error Messages Out of the Audit Write Failure Log * style: Sort Audit Log Spec Imports * fix: Sanitize Admin Handler Error Logs and Dispatch System Audit Writes Without Waiting |
||
|
|
2451bf54cf
|
🛡️ fix: Restrict System Grants to Role Principals (#12491)
* 🛡️ fix: restrict system grants to role principals only Narrows GrantPrincipalType to PrincipalType.ROLE, rejecting GROUP and USER with 400. Removes grant cascade cleanup from group/user deletion handlers and their route wiring since only roles can hold grants. * 🛡️ fix: address review findings for grants roles-only restriction Add missing GROUP rejection test for revokeGrant (symmetric with getPrincipalGrants and assignGrant coverage), add extensibility comment to GrantPrincipalType, and document the checkRoleExists guard. |
||
|
|
2e3d66cfe2
|
👥 feat: Admin Groups API Endpoints (#12387)
* feat: add listGroups and deleteGroup methods to userGroup
* feat: add admin groups handler factory and Express routes
* fix: address convention violations in admin groups handlers
* fix: address Copilot review findings in admin groups handlers
- Escape regex in listGroups to prevent injection/ReDoS
- Validate ObjectId format in all handlers accepting id/userId params
- Replace N+1 findUser loop with batched findUsers query
- Remove unused findGroupsByMemberId from dep interface
- Map Mongoose ValidationError to 400 in create/update handlers
- Validate name in updateGroupHandler (reject empty/whitespace)
- Handle null updateGroupById result (race condition)
- Tighten error message matching in add/remove member handlers
* test: add unit tests for admin groups handlers
* fix: address code review findings for admin groups
Atomic delete/update handlers (single DB trip), pass through
idOnTheSource, add removeMemberById for non-ObjectId members,
deduplicate member results, fix error message exposure, add hard
cap/sort to listGroups, replace GroupListFilter with Pick of
GroupFilterOptions, validate memberIds as array, trim name in
update, fix import order, and improve test hygiene with fresh
IDs per test.
* fix: cascade cleanup, pagination, and test coverage for admin groups
Add deleteGrantsForPrincipal to systemGrant data layer and wire cascade
cleanup (Config, AclEntry, SystemGrant) into deleteGroupHandler. Add
limit/offset pagination to getGroupMembers. Guard empty PATCH bodies with
400. Remove dead type guard and unnecessary type cast. Add 11 new tests
covering cascade delete, idempotent member removal, empty update, search
filter, 500 error paths, and pagination.
* fix: harden admin groups with cascade resilience, type safety, and fallback removal
Wrap cascade cleanup in inner try/catch so partial failure logs but still
returns 200 (group is already deleted). Replace Record<string, unknown> on
deleteAclEntries with proper typed filter. Log warning for unmapped user
ObjectIds in createGroup memberIds. Add removeMemberById fallback when
removeUserFromGroup throws User not found for ObjectId-format userId.
Extract VALID_GROUP_SOURCES constant. Add 3 new tests (60 total).
* refactor: add countGroups, pagination, and projection type to data layer
Extract buildGroupQuery helper, add countGroups method, support
limit/offset/skip in listGroups, standardize session handling to
.session(session ?? null), and tighten projection parameter from
Record<string, unknown> to Record<string, 0 | 1>.
* fix: cascade resilience, pagination, validation, and error clarity for admin groups
- Use Promise.allSettled for cascade cleanup so all steps run even if
one fails; log individual rejections
- Echo deleted group id in delete response
- Add countGroups dep and wire limit/offset pagination for listGroups
- Deduplicate memberIds before computing total in getGroupMembers
- Use { memberIds: 1 } projection in getGroupMembers
- Cap memberIds at 500 entries in createGroup
- Reject search queries exceeding 200 characters
- Clarify addGroupMember error for non-ObjectId userId
- Document deleted-user fallback limitation in removeGroupMember
* test: extend handler and DB-layer test coverage for admin groups
Handler tests: projection assertion, dedup total, memberIds cap,
search max length, non-ObjectId memberIds passthrough, cascade partial
failure resilience, dedup scenarios, echo id in delete response.
DB-layer tests: listGroups sort/filter/pagination, countGroups,
deleteGroup, removeMemberById, deleteGrantsForPrincipal.
* fix: cast group principalId to ObjectId for ACL entry cleanup
deleteAclEntries is a thin deleteMany wrapper with no type casting,
but grantPermission stores group principalId as ObjectId. Passing the
raw string from req.params would leave orphaned ACL entries on group
deletion.
* refactor: remove redundant pagination clamping from DB listGroups
Handler already clamps limit/offset at the API boundary. The DB
method is a general-purpose building block and should not re-validate.
* fix: add source and name validation, import order, and test coverage for admin groups
- Validate source against VALID_GROUP_SOURCES in createGroupHandler
- Cap name at 500 characters in both create and update handlers
- Document total as upper bound in getGroupMembers response
- Document ObjectId requirement for deleteAclEntries in cascade
- Fix import ordering in test file (local value after type imports)
- Add tests for updateGroup with description, email, avatar fields
- Add tests for invalid source and name max-length in both handlers
* fix: add field length caps, flatten nested try/catch, and fix logger level in admin groups
Add max-length validation for description, email, avatar, and
idOnTheSource in create/update handlers. Extract removeObjectIdMember
helper to flatten nested try/catch per never-nesting convention. Downgrade
unmapped-memberIds log from error to warn. Fix type import ordering and
add missing await in removeMemberById for consistency.
|