* 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
* Shared Role-Sync Core
* Environment Configuration
* Browser OpenID Wiring & improved shared component
* API Auth Wiring
* Improved Role Lookup
* added example for sync env
* small simplification
* protect existing manual assigned ADMIN Roles
* fix: Apply OpenID role-sync fallback for present-but-empty claims
Both role-sync call sites skipped on a falsy `openIdRoleValues`, treating an
empty claim string ('') the same as a missing claim and returning before
`selectOpenIdRole` could apply the configured fallback role. An IdP emitting
an empty roles claim for a user with no mapped groups left the stale local
role in place instead of the authoritative fallback.
Skip only when the helper returns `undefined` (missing/invalid), letting an
empty string flow through to fallback selection — consistent with how an
empty array is already handled. Adds regression coverage on both the OpenID
strategy and the remote-agent API auth paths.
* refactor: Address OpenID role-sync review feedback
- role.ts: reuse the shared escapeRegExp util instead of a local escapeRegex
duplicate, matching prompt/skill/user/userGroup methods (Copilot).
- openidStrategy.js / remoteAgentAuth.ts: make the tenantStorage.run callbacks
async so the documented ALS contract is satisfied and tenant context cannot
be lost during Mongoose execution; the wrapped lookups/updates are already
async, so behavior is unchanged (codex P2).
* fix: Harden OpenID role-sync claim and fallback handling
Addresses the second Codex review cycle (P2 findings):
- Apply fallback when the claim is absent: getOpenIdRolesForOpenIdSync now
returns an empty list (not undefined) when the token source exists but has
no usable claim value, so callers still run selection and assign the
configured fallback instead of leaving a stale elevated role. A truly
unavailable source still returns undefined and skips sync.
- Resolve group overage for access tokens too: the _claim_names/_claim_sources
overage path previously only ran for claimSource 'id'; Entra also moves an
oversized groups claim into access tokens, so 'access'+'groups' (the only
source supported by remote-agent API sync) now resolves overage as well.
- Allow system fallback roles for tenant users: getLibreChatRolesForOpenIdSync
treats SystemRoles (e.g. USER) as always-available canonical names, since
they are provisioned globally at startup and a tenant-scoped lookup may not
return them — preventing a spurious 'configured roles do not exist: USER'.
Adds unit and strategy-level coverage for all three.
* fix: Tighten OpenID role-sync tenant scoping and config validation
Addresses the third Codex review cycle:
- Constrain base-user role lookups to base roles (P2): findRolesByNames now
filters to roles with an unset tenantId when no tenant ALS context is active,
so a base user cannot match — and be assigned — a role that only exists within
a tenant. Tenant-scoped lookups remain controlled by the isolation plugin.
- Re-enforce tenant login policy after role sync (P2): when role sync changes a
tenant user's role, the OpenID strategy re-resolves the tenant appConfig and
re-checks allowedDomains, so a token cannot complete login under the previous
role's looser policy.
- Skip role-sync-specific validation when disabled (P3): getOpenIdRoleSyncOptions
returns disabled options before validating role-sync settings, so a stale or
mistyped value no longer breaks OpenID login while the feature is off.
Adds unit and strategy-level coverage for all three.
* fix: Run base role lookups under system context for strict isolation
Follow-up to the base-role scoping fix (Codex P1). With TENANT_ISOLATION_STRICT=true,
the tenant-isolation pre('find') hook throws on a context-less query before the manual
tenantId filter is honored, so base OpenID/remote-agent auth would 500 instead of
validating base roles. findRolesByNames now runs the no-context lookup inside
runAsSystem (SYSTEM_TENANT_ID), bypassing strict-mode injection while still applying an
explicit base-role (tenantId unset) filter. Adds a strict-mode regression test.
---------
Co-authored-by: Peter Rothlaender <peter.rothlaender@ginkgo.com>