LibreChat/packages/api/src/auth
Danny Avila 8b58ebc4d5
🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins (#16779)
* 🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins

SAML, LDAP and social logins looked the user up and then inserted it
with nothing in between, so two first logins for one new identity both
inserted and the unique index failed the second with E11000.

Every strategy now provisions first-login users in packages/api:
createUserOnce inserts through createUserIfAbsent and, on user_exists,
repeats the strategy's own lookup and resolves to the account that won,
once its creator finished provisioning it (its start balance exists when
one is configured), admitted exactly as a found account (a tenant
account resolves its tenant config and that config's email-domain policy
applies). provisionSamlUser, provisionLdapUser and provisionSocialUser
own the create / recover / refresh decision, so a recovered account gets
the same refresh as any account the login finds (claimSamlIdentity, the
LDAP directory overwrite, handleExistingUser), and the CJS strategies
only pass their models and services and map the result to passport.
The lookups take a plain FindUserByFields and the contracts carry
UserRecord and NewUserData. createOpenIDUser now goes through
createUserOnce.

Related to #16766

* ⚡ perf: Read a Recovered Account's Config and Balance Together

After losing the insert race, createUserOnce resolved the tenant config
and only then read the start balance, although the balance check now
depends only on the creation config. Both reads start together.
2026-10-05 17:57:23 -04:00
..
openid 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
passkey ⚙️ feat: Make the Per-User Passkey Cap Configurable (#16259) 2026-10-01 03:46:17 +00:00
adminPkce.spec.ts
agent.spec.ts
agent.ts
allowedAddresses.ts
codeapi.spec.ts 🪵 fix: Log Code API Auth Header Failures With Request Context (#15592) 2026-09-04 10:38:49 -04:00
codeapi.ts 🪵 fix: Log Code API Auth Header Failures With Request Context (#15592) 2026-09-04 10:38:49 -04:00
credentials.eviction.spec.ts 🧯 fix: Outlast Failed Auth Cache Eviction on Credential Changes (#16435) 2026-10-01 03:46:18 +00:00
credentials.spec.ts 🔑 feat: Passkey Authentication with WebAuthn Sign-In and Management (#14715) 2026-10-01 03:46:16 +00:00
credentials.ts 🔑 feat: Passkey Authentication with WebAuthn Sign-In and Management (#14715) 2026-10-01 03:46:16 +00: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 📧 feat: add email address change (#14597) 2026-10-01 03:46:16 +00: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 🧧 fix: Redeem Admin OAuth Codes Only Once (#16513) 2026-09-29 12:09:13 -04:00
exchange.ts 🧧 fix: Redeem Admin OAuth Codes Only Once (#16513) 2026-09-29 12:09:13 -04: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
index.ts 🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins (#16779) 2026-10-05 17:57:23 -04:00
invite.spec.ts
invite.ts
ip.ts
ldap.ts 🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins (#16779) 2026-10-05 17:57:23 -04:00
limiter.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
localRefresh.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
login.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
oidc.cognito.spec.ts 🔐 feat: Support Cognito Access Tokens for Agent Management (#16224) 2026-09-22 20:37:40 -04:00
oidc.spec.ts 🔐 feat: Support Cognito Access Tokens for Agent Management (#16224) 2026-09-22 20:37:40 -04:00
oidc.ts 🔐 feat: Support Cognito Access Tokens for Agent Management (#16224) 2026-09-22 20:37:40 -04:00
openid.spec.ts 🚪 fix: Let Concurrent First OpenID Logins Continue as the New User (#16778) 2026-10-05 17:56:57 -04:00
openid.ts 🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins (#16779) 2026-10-05 17:57:23 -04:00
openidRoleSync.spec.ts
openidRoleSync.ts
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 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
passwordReset.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
passwordResetUpdate.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
provision.spec.ts 🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins (#16779) 2026-10-05 17:57:23 -04:00
provision.ts 🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins (#16779) 2026-10-05 17:57:23 -04:00
proxy.ts
recovery.spec.ts 🗝️ fix: Strengthen Two-Factor Recovery Credentials (#16742) 2026-10-04 12:16:37 -04:00
recovery.ts 🗝️ fix: Strengthen Two-Factor Recovery Credentials (#16742) 2026-10-04 12:16:37 -04:00
refresh.spec.ts
refresh.ts
reuse.spec.ts
reuse.ts
saml.spec.ts
saml.ts 🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins (#16779) 2026-10-05 17:57:23 -04:00
share.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02:00
social.ts 🔁 fix: Recover Concurrent First SAML, LDAP and Social Logins (#16779) 2026-10-05 17:57:23 -04: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 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +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 🧯 fix: Outlast Failed Auth Cache Eviction on Credential Changes (#16435) 2026-10-01 03:46:18 +00:00
userDocCache.ts 🔐 feat: Enforce Required Two-Factor Authentication (#14731) 2026-10-01 23:39:51 +02: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