Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(ua-login): improve lock error message & disable lock when lockout is disabled

x03220548f17f4d8db4
diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.ts
index 5977476830..8aec163713 100644
--- a/backend/src/services/identity-ua/identity-ua-service.ts
+++ b/backend/src/services/identity-ua/identity-ua-service.ts
@@ -84,18 +84,20 @@ export const identityUaServiceFactory = ({
const LOCKOUT_KEY = `lockout:identity:${identityUa.identityId}:${IdentityAuthMethod.UNIVERSAL_AUTH}:${clientId}`;
- let lock: Awaited<ReturnType<typeof keyStore.acquireLock>>;
- try {
- lock = await keyStore.acquireLock([KeyStorePrefixes.IdentityLockoutLock(LOCKOUT_KEY)], 500, {
- retryCount: 3,
- retryDelay: 300,
- retryJitter: 100
- });
- } catch (e) {
- logger.info(
- `identity login failed to acquire lock [identityId=${identityUa.identityId}] [authMethod=${IdentityAuthMethod.UNIVERSAL_AUTH}]`
- );
- throw new RateLimitError({ message: "Rate limit exceeded" });
+ let lock: Awaited<ReturnType<typeof keyStore.acquireLock>> | undefined;
+ if (identityUa.lockoutEnabled) {
+ try {
+ lock = await keyStore.acquireLock([KeyStorePrefixes.IdentityLockoutLock(LOCKOUT_KEY)], 500, {
+ retryCount: 3,
+ retryDelay: 300,
+ retryJitter: 100
+ });
+ } catch (e) {
+ logger.info(
+ `identity login failed to acquire lock [identityId=${identityUa.identityId}] [authMethod=${IdentityAuthMethod.UNIVERSAL_AUTH}]`
+ );
+ throw new RateLimitError({ message: "Failed to acquire lock: rate limit exceeded" });
+ }
}
try {
@@ -257,7 +259,7 @@ export const identityUaServiceFactory = ({
...accessTokenTTLParams
};
} finally {
- await lock.release();
+ if (lock) await lock.release();
}
};