LibreChat/packages/api/src/auth
Marco Beretta 2ad2c1c14b
🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466)
* perf: Serve JWT Bearer User Lookups From the Auth User Cache

* perf: Batch Agent Permission Reads on the File Access Path

* perf: Remember a Loaded Google Service Key Across Endpoint Config Reads

* perf: Run Independent Startup, Tool, Skill and Erasure Reads Concurrently

* fix: Drop JWT User Cache Writes That Race a User Mutation

Confirm each cache write with a second read and evict when the user changed,
so an in-flight lookup cannot repopulate an entry a credential change just
evicted. The cache mode now arrives through the loader dependencies.

* refactor: Move Agent Skill Access Reads Into packages/api

The chat-completions and Responses controllers call loadSkillAccess instead of
orchestrating the three reads in CJS. The preview route spec mocks the batched
file access helper the middleware now calls.

* test: Cover Agent File Access, JWT Bursts and Remote Skill Reads End to End

* fix: Serve a Cached JWT User Only While Its updatedAt Is Current

A cache hit now reads the stored updatedAt and deletion fence instead of the
fence alone, so a document cached from a read that raced a user mutation is
never served, even when the write landed after that mutation's eviction.

* refactor: Move Startup Migration Checks Into packages/api

* refactor: Inject the Startup Migration Checks Instead of Mongoose Models

* fix: Serve Cached OpenID Users Only While Their updatedAt Is Current

Moves the freshness check into getCurrentCachedAuthUserDoc and uses it on the
OpenID bearer path as well as the local JWT one, so a document cached from a
read that raced a credential or role change is never served there either.

Fixes berry-13/LibreChat#432

* fix: Compare Authorization Fields on Every Auth Cache Hit

updatedAt has millisecond resolution, so the freshness read also compares the
token retirement stamps, role, tenant and two-factor state.

* fix: Annotate the Auth Freshness Projection for Isolated Declarations

* perf: Reuse the OpenID Cache Freshness Read for Deletion Admission

A cache hit already proved the deletion fence is clear, so only users read from
the database take the separate fence query.

* refactor: Keep the OpenID Cache Freshness and Fence Decisions in packages/api

* test: Exercise JWT Cache Freshness Against Real User Methods in MongoDB

* fix: Stamp the JWT User Lookup So the Cache Write Fence Applies

* fix: Reload a Google Service Key File When It Changes or Disappears

The availability check remembers a loaded key only while the file's mtime and
size are unchanged, and fetches URL sources every time as before.

* fix: Recheck a Service Key File After a Permission Change
2026-10-30 00:24:08 +01:00
..
__fixtures__ 🔐 fix: Hash Passwords on a Worker Pool and Surface API Key Lookup Failures (#17261) 2026-10-19 22:13:31 +02:00
openid 🔓 fix: Prevent 30-Second OpenID Refresh Stalls After a Discarded Prerender (#17174) 2026-10-15 16:02:28 -07:00
passkey 🗂️ feat: Audit MCP, Code Worker, Langfuse, Skill Credential, Passkey and Audit Log Access (#17054) 2026-10-15 00:30:26 +02:00
adminPkce.spec.ts 🔐 fix: Keep the Admin OpenID State So PKCE Holds When the IdP Omits S256 (#17478) 2026-10-28 18:33:12 +01:00
agent.spec.ts
agent.ts
allowedAddresses.ts ✂️ refactor: Remove Dead Helpers, Classes and Dependencies From packages/api (#17118) 2026-10-16 15:43:12 +02:00
codeapi.spec.ts
codeapi.ts 🧑‍✈️ feat: Enroll Machines Through Explicit Browser Approval (#17344) 2026-10-22 16:54:00 +02:00
credentials.eviction.spec.ts 🧊 fix: Fence Auth User Cache Writes After Eviction and Evict Favorite Holders (#17505) 2026-10-29 17:44:51 +01:00
domain.spec.ts
domain.ts 🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins (#16779) 2026-10-05 17:57:23 -04:00
email.spec.ts 📧 feat: add email address change (#14597) 2026-10-01 03:46:16 +00:00
email.ts 🕵️ fix: Redact Email Addresses and IPs From Auth Flow Logs (#16994) 2026-10-12 10:50:56 +02:00
emailChangeStore.spec.ts 📧 feat: add email address change (#14597) 2026-10-01 03:46:16 +00:00
emailChangeStore.ts 📧 feat: add email address change (#14597) 2026-10-01 03:46:16 +00:00
enrollment.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
exchange.spec.ts
exchange.ts 🔐 fix: Keep the Admin OpenID State So PKCE Holds When the IdP Omits S256 (#17478) 2026-10-28 18:33:12 +01:00
gates.spec.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
gates.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
googleRefresh.spec.ts
googleRefresh.ts ⏱️ fix: Bound Remaining Outbound Calls With Timeout Budgets (#17468) 2026-10-29 09:55:18 +01:00
hash-worker.ts 🔐 fix: Hash Passwords on a Worker Pool and Surface API Key Lookup Failures (#17261) 2026-10-19 22:13:31 +02:00
hashing.spec.ts 🔕 fix: Quiet Client Disconnects, Fall Back When Hash Workers Fail, Log Speech Truncation (#17278) 2026-10-20 10:47:15 +02:00
hashing.ts 🔕 fix: Quiet Client Disconnects, Fall Back When Hash Workers Fail, Log Speech Truncation (#17278) 2026-10-20 10:47:15 +02:00
index.ts 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
invite.spec.ts
invite.ts
ip.ts
jwt.integration.spec.ts 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
jwt.spec.ts 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
jwt.ts 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
ldap.ts 🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links (#17351) 2026-10-22 22:49:54 +02:00
limiter.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
localRefresh.ts 🪪 fix: Boot-Paint a Cached Theme Only for Its Signed-In Owner (#16926) 2026-10-14 11:08:53 +02:00
login.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
oidc.cognito.spec.ts
oidc.spec.ts
oidc.ts
openid.spec.ts 🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links (#17351) 2026-10-22 22:49:54 +02:00
openid.ts 🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links (#17351) 2026-10-22 22:49:54 +02:00
openidRoleSync.spec.ts 📜 feat: Audit Admin Role, Group, Config and IdP Role Mutations (#17052) 2026-10-14 23:57:07 +02:00
openidRoleSync.ts 🪶 fix: Time Out Client Refresh and Trim Lodash Imports (#17467) 2026-10-27 23:30:08 +01:00
passkey.spec.ts ⚙️ feat: Make the Per-User Passkey Cap Configurable (#16259) 2026-10-01 03:46:17 +00:00
passkey.ts ⚙️ feat: Make the Per-User Passkey Cap Configurable (#16259) 2026-10-01 03:46:17 +00:00
password.ts
passwordReset.spec.ts 🔐 fix: Hash Passwords on a Worker Pool and Surface API Key Lookup Failures (#17261) 2026-10-19 22:13:31 +02:00
passwordReset.ts 🔐 fix: Hash Passwords on a Worker Pool and Surface API Key Lookup Failures (#17261) 2026-10-19 22:13:31 +02:00
passwordResetUpdate.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
provision.spec.ts 🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links (#17351) 2026-10-22 22:49:54 +02:00
provision.ts 🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links (#17351) 2026-10-22 22:49:54 +02:00
proxy.ts
recovery.spec.ts 🔏 fix: Encrypt Provider Keys With v3, Reject Plaintext in decryptV2 and Default to Strong Backup Codes (#17051) 2026-10-13 22:19:37 +02:00
recovery.ts 🔏 fix: Encrypt Provider Keys With v3, Reject Plaintext in decryptV2 and Default to Strong Backup Codes (#17051) 2026-10-13 22:19:37 +02:00
refresh.spec.ts 📧 fix: Log User IDs Instead of Emails in Admin Panel Auth Flow (#17032) 2026-10-13 08:42:57 +02:00
refresh.ts 📧 fix: Log User IDs Instead of Emails in Admin Panel Auth Flow (#17032) 2026-10-13 08:42:57 +02:00
reuse.spec.ts
reuse.ts
saml.spec.ts
saml.ts 🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links (#17351) 2026-10-22 22:49:54 +02:00
share.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
social.ts 🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links (#17351) 2026-10-22 22:49:54 +02:00
tempuser.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
twoFactor.spec.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
twoFactor.ts 🪪 fix: Boot-Paint a Cached Theme Only for Its Signed-In Owner (#16926) 2026-10-14 11:08:53 +02:00
user.spec.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
user.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
userDocCache.spec.ts 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
userDocCache.ts 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
verification.spec.ts 🔑 feat: Passkey Authentication with WebAuthn Sign-In and Management (#14715) 2026-10-01 03:46:16 +00:00
verification.ts 🔑 feat: Passkey Authentication with WebAuthn Sign-In and Management (#14715) 2026-10-01 03:46:16 +00:00