Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
remove throw from helper function
adilsona2b26f01e5d6
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.tsindex d2fd2af17e..aa96c8ae94 100644--- a/backend/src/ee/services/audit-log/audit-log-types.ts+++ b/backend/src/ee/services/audit-log/audit-log-types.ts@@ -1156,6 +1156,7 @@ interface LoginIdentityUniversalAuthFailedEvent {clientId: string;identityId: string | null;reason: string;+ message: string;};}diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.tsindex 34cff06600..a0149e897a 100644--- a/backend/src/services/identity-ua/identity-ua-service.ts+++ b/backend/src/services/identity-ua/identity-ua-service.ts@@ -38,6 +38,7 @@ import { TIdentityUaDALFactory } from "./identity-ua-dal";import {TAttachUaDTO,TClearUaLockoutsDTO,+ TCreateLoginFailedAuditLogDTO,TCreateUaClientSecretDTO,TGetUaClientSecretsDTO,TGetUaDTO,@@ -45,7 +46,6 @@ import {TLoginUaDTO,TRevokeUaClientSecretDTO,TRevokeUaDTO,- TThrowUnauthorizedWithAuditLogDTO,TUpdateUaDTO} from "./identity-ua-types";@@ -84,7 +84,7 @@ export const identityUaServiceFactory = ({identityDAL,auditLogService}: TIdentityUaServiceFactoryDep) => {- const throwUnauthorizedWithAuditLog = async ({+ const createLoginFailedAuditLog = async ({message,clientId,identityId,@@ -93,7 +93,7 @@ export const identityUaServiceFactory = ({ip,userAgent,userAgentType- }: TThrowUnauthorizedWithAuditLogDTO): Promise<never> => {+ }: TCreateLoginFailedAuditLogDTO): Promise<void> => {await auditLogService.createAuditLog({actor: { type: ActorType.UNKNOWN_USER, metadata: {} },orgId,@@ -102,17 +102,16 @@ export const identityUaServiceFactory = ({userAgentType,event: {type: EventType.LOGIN_IDENTITY_UA_AUTH_FAILED,- metadata: { clientId, identityId, reason }+ metadata: { clientId, identityId, reason, message }}});- throw new UnauthorizedError({ message });};const login = async ({ clientId, clientSecret, ip, organizationSlug, userAgent, userAgentType }: TLoginUaDTO) => {const appCfg = getConfig();const identityUa = await identityUaDAL.findOne({ clientId });if (!identityUa) {- await throwUnauthorizedWithAuditLog({+ await createLoginFailedAuditLog({message: "Invalid credentials",clientId,identityId: null,@@ -121,6 +120,7 @@ export const identityUaServiceFactory = ({userAgent,userAgentType});+ throw new UnauthorizedError({ message: "Invalid credentials" });}const identity = await identityDAL.findById(identityUa.identityId);@@ -146,7 +146,7 @@ export const identityUaServiceFactory = ({}if (lockout && lockout.lockedOut) {- await throwUnauthorizedWithAuditLog({+ await createLoginFailedAuditLog({message: "This identity auth method is temporarily locked, please try again later",clientId,identityId: identityUa.identityId,@@ -156,6 +156,9 @@ export const identityUaServiceFactory = ({userAgent,userAgentType});+ throw new UnauthorizedError({+ message: "This identity auth method is temporarily locked, please try again later"+ });}const clientSecretPrefix = clientSecret.slice(0, 4);@@ -197,7 +200,7 @@ export const identityUaServiceFactory = ({}if (lockout.lockedOut) {- await throwUnauthorizedWithAuditLog({+ await createLoginFailedAuditLog({message: "This identity auth method is temporarily locked, please try again later",clientId,identityId: identityUa.identityId,@@ -207,6 +210,9 @@ export const identityUaServiceFactory = ({userAgent,userAgentType});+ throw new UnauthorizedError({+ message: "This identity auth method is temporarily locked, please try again later"+ });}lockout.failedAttempts += 1;@@ -234,7 +240,7 @@ export const identityUaServiceFactory = ({}}- await throwUnauthorizedWithAuditLog({+ await createLoginFailedAuditLog({message: "Invalid credentials",clientId,identityId: identityUa.identityId,@@ -244,6 +250,7 @@ export const identityUaServiceFactory = ({userAgent,userAgentType});+ throw new UnauthorizedError({ message: "Invalid credentials" });} else if (lockout) {// If credentials are valid, clear any existing lockout recordawait keyStore.deleteItem(LOCKOUT_KEY);@@ -261,7 +268,7 @@ export const identityUaServiceFactory = ({isClientSecretRevoked: true});- await throwUnauthorizedWithAuditLog({+ await createLoginFailedAuditLog({message: "Access denied due to expired client secret",clientId,identityId: identityUa.identityId,@@ -271,6 +278,7 @@ export const identityUaServiceFactory = ({userAgent,userAgentType});+ throw new UnauthorizedError({ message: "Access denied due to expired client secret" });}}@@ -280,7 +288,7 @@ export const identityUaServiceFactory = ({await identityUaClientSecretDAL.updateById(validClientSecretInfo.id, {isClientSecretRevoked: true});- await throwUnauthorizedWithAuditLog({+ await createLoginFailedAuditLog({message: "Access denied due to client secret usage limit reached",clientId,identityId: identityUa.identityId,@@ -290,6 +298,7 @@ export const identityUaServiceFactory = ({userAgent,userAgentType});+ throw new UnauthorizedError({ message: "Access denied due to client secret usage limit reached" });}const accessTokenTTLParams =@@ -321,7 +330,7 @@ export const identityUaServiceFactory = ({});if (!subOrgMembership) {- await throwUnauthorizedWithAuditLog({+ await createLoginFailedAuditLog({message: `Identity not authorized to access sub organization ${organizationSlug}`,clientId,identityId: identityUa.identityId,@@ -331,6 +340,9 @@ export const identityUaServiceFactory = ({userAgent,userAgentType});+ throw new UnauthorizedError({+ message: `Identity not authorized to access sub organization ${organizationSlug}`+ });}subOrganizationId = subOrg.id;diff --git a/backend/src/services/identity-ua/identity-ua-types.ts b/backend/src/services/identity-ua/identity-ua-types.tsindex 8ed65c756f..4c9713557c 100644--- a/backend/src/services/identity-ua/identity-ua-types.ts+++ b/backend/src/services/identity-ua/identity-ua-types.ts@@ -72,7 +72,7 @@ export type TGetUniversalAuthClientSecretByIdDTO = {clientSecretId: string;} & Omit<TProjectPermission, "projectId">;-export type TThrowUnauthorizedWithAuditLogDTO = {+export type TCreateLoginFailedAuditLogDTO = {message: string;clientId: string;identityId: string | null;