Skip to content

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

apply requested changes

adilsonc3cee75cc2cb
diff --git a/backend/src/ee/services/audit-log/audit-log-service.ts b/backend/src/ee/services/audit-log/audit-log-service.ts
index 81d0f1c84e..4d1dcc37da 100644
--- a/backend/src/ee/services/audit-log/audit-log-service.ts
+++ b/backend/src/ee/services/audit-log/audit-log-service.ts
@@ -22,34 +22,6 @@ type TAuditLogServiceFactoryDep = {
auditLogQueue: TAuditLogQueueServiceFactory;
};
-// Events that don't require projectId or orgId (login events where org context may not be available)
-const EVENTS_WITHOUT_ORG_OR_PROJECT = new Set<EventType>([
- EventType.LOGIN_IDENTITY_UNIVERSAL_AUTH,
- EventType.LOGIN_IDENTITY_UA_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_KUBERNETES_AUTH,
- EventType.LOGIN_IDENTITY_KUBERNETES_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_GCP_AUTH,
- EventType.LOGIN_IDENTITY_GCP_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_AWS_AUTH,
- EventType.LOGIN_IDENTITY_AWS_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_OIDC_AUTH,
- EventType.LOGIN_IDENTITY_OIDC_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_AZURE_AUTH,
- EventType.LOGIN_IDENTITY_AZURE_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_JWT_AUTH,
- EventType.LOGIN_IDENTITY_JWT_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_ALICLOUD_AUTH,
- EventType.LOGIN_IDENTITY_ALICLOUD_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_TLS_CERT_AUTH,
- EventType.LOGIN_IDENTITY_TLS_CERT_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_OCI_AUTH,
- EventType.LOGIN_IDENTITY_OCI_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_LDAP_AUTH,
- EventType.LOGIN_IDENTITY_LDAP_AUTH_FAILED,
- EventType.LOGIN_IDENTITY_SPIFFE_AUTH,
- EventType.LOGIN_IDENTITY_SPIFFE_AUTH_FAILED
-]);
-
export const auditLogServiceFactory = ({
auditLogDAL,
clickhouseAuditLogDAL,
@@ -137,7 +109,8 @@ export const auditLogServiceFactory = ({
if (appCfg.DISABLE_AUDIT_LOG_GENERATION) {
return;
}
- if (!EVENTS_WITHOUT_ORG_OR_PROJECT.has(data.event.type)) {
+ // Events that don't require projectId or orgId (login events where org context may not be available)
+ if (data.event.type !== EventType.LOGIN_IDENTITY_UNIVERSAL_AUTH) {
if (!data.projectId && !data.orgId)
throw new BadRequestError({ message: "Must specify either project id or org id" });
}
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 797448a850..a91e801799 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -1166,7 +1166,7 @@ interface LoginIdentityUniversalAuthFailedEvent {
metadata: {
clientId: string;
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1323,7 +1323,7 @@ interface LoginIdentityKubernetesAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_KUBERNETES_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1421,7 +1421,7 @@ interface LoginIdentityGcpAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_GCP_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1483,7 +1483,7 @@ interface LoginIdentityAwsAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_AWS_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1543,7 +1543,7 @@ interface LoginIdentityAliCloudAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_ALICLOUD_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1599,7 +1599,7 @@ interface LoginIdentityTlsCertAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_TLS_CERT_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1655,7 +1655,7 @@ interface LoginIdentityOciAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_OCI_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1713,7 +1713,7 @@ interface LoginIdentityAzureAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_AZURE_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1771,7 +1771,7 @@ interface LoginIdentityLdapAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_LDAP_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1893,7 +1893,7 @@ interface LoginIdentityOidcAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_OIDC_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -1961,7 +1961,7 @@ interface LoginIdentityJwtAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_JWT_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
@@ -2031,7 +2031,7 @@ interface LoginIdentitySpiffeAuthFailedEvent {
type: EventType.LOGIN_IDENTITY_SPIFFE_AUTH_FAILED;
metadata: {
identityId: string | null;
- reason: string;
+ reasonCode: string;
message: string;
};
}
diff --git a/backend/src/server/routes/v1/identity-alicloud-auth-router.ts b/backend/src/server/routes/v1/identity-alicloud-auth-router.ts
index a49d2e909a..feaf8d6bb6 100644
--- a/backend/src/server/routes/v1/identity-alicloud-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-alicloud-auth-router.ts
@@ -119,16 +119,27 @@ export const registerIdentityAliCloudAuthRouter = async (server: FastifyZodProvi
accessTokenMaxTTL: identityAliCloudAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_ALICLOUD_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts b/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts
index 2d1b3ddf77..bdd794226e 100644
--- a/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-aws-iam-auth-router.ts
@@ -86,16 +86,27 @@ export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider)
accessTokenMaxTTL: identityAwsAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_AWS_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-azure-auth-router.ts b/backend/src/server/routes/v1/identity-azure-auth-router.ts
index c882cd4866..f8b7ee0c17 100644
--- a/backend/src/server/routes/v1/identity-azure-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-azure-auth-router.ts
@@ -81,16 +81,27 @@ export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvider
accessTokenMaxTTL: identityAzureAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_AZURE_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-gcp-auth-router.ts b/backend/src/server/routes/v1/identity-gcp-auth-router.ts
index 78bf46d4ab..ddd117ea9a 100644
--- a/backend/src/server/routes/v1/identity-gcp-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-gcp-auth-router.ts
@@ -81,16 +81,27 @@ export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider)
accessTokenMaxTTL: identityGcpAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_GCP_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-jwt-auth-router.ts b/backend/src/server/routes/v1/identity-jwt-auth-router.ts
index bbb0024ce2..ffe14269c9 100644
--- a/backend/src/server/routes/v1/identity-jwt-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-jwt-auth-router.ts
@@ -157,16 +157,27 @@ export const registerIdentityJwtAuthRouter = async (server: FastifyZodProvider)
accessTokenMaxTTL: identityJwtAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_JWT_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-kubernetes-auth-router.ts b/backend/src/server/routes/v1/identity-kubernetes-auth-router.ts
index 58f08717a1..46aa20732c 100644
--- a/backend/src/server/routes/v1/identity-kubernetes-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-kubernetes-auth-router.ts
@@ -102,16 +102,27 @@ export const registerIdentityKubernetesRouter = async (server: FastifyZodProvide
accessTokenMaxTTL: identityKubernetesAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_KUBERNETES_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-ldap-auth-router.ts b/backend/src/server/routes/v1/identity-ldap-auth-router.ts
index 0f981a9fd6..8c67c0cf89 100644
--- a/backend/src/server/routes/v1/identity-ldap-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-ldap-auth-router.ts
@@ -228,16 +228,27 @@ export const registerIdentityLdapAuthRouter = async (server: FastifyZodProvider)
accessTokenMaxTTL: identityLdapAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_LDAP_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-oci-auth-router.ts b/backend/src/server/routes/v1/identity-oci-auth-router.ts
index 10e978561e..51af55c00b 100644
--- a/backend/src/server/routes/v1/identity-oci-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-oci-auth-router.ts
@@ -98,16 +98,27 @@ export const registerIdentityOciAuthRouter = async (server: FastifyZodProvider)
accessTokenMaxTTL: identityOciAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_OCI_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-oidc-auth-router.ts b/backend/src/server/routes/v1/identity-oidc-auth-router.ts
index f93cc0d143..37c4b26704 100644
--- a/backend/src/server/routes/v1/identity-oidc-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-oidc-auth-router.ts
@@ -109,16 +109,27 @@ export const registerIdentityOidcAuthRouter = async (server: FastifyZodProvider)
accessTokenMaxTTL: identityOidcAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_OIDC_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-spiffe-auth-router.ts b/backend/src/server/routes/v1/identity-spiffe-auth-router.ts
index 1ee87de00e..132005a1f9 100644
--- a/backend/src/server/routes/v1/identity-spiffe-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-spiffe-auth-router.ts
@@ -153,16 +153,27 @@ export const registerIdentitySpiffeAuthRouter = async (server: FastifyZodProvide
accessTokenMaxTTL: identitySpiffeAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_SPIFFE_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-tls-cert-auth-router.ts b/backend/src/server/routes/v1/identity-tls-cert-auth-router.ts
index a73709d92d..b7eafb6bcc 100644
--- a/backend/src/server/routes/v1/identity-tls-cert-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-tls-cert-auth-router.ts
@@ -112,16 +112,27 @@ export const registerIdentityTlsCertAuthRouter = async (server: FastifyZodProvid
accessTokenMaxTTL: identityTlsCertAuth.accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail?.orgId && error.detail?.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_TLS_CERT_AUTH_FAILED,
metadata: {
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/server/routes/v1/identity-universal-auth-router.ts b/backend/src/server/routes/v1/identity-universal-auth-router.ts
index 11fe97ddd0..f4f47f5e42 100644
--- a/backend/src/server/routes/v1/identity-universal-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-universal-auth-router.ts
@@ -106,17 +106,28 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
accessTokenMaxTTL
};
} catch (error) {
- if (error instanceof UnauthorizedError && error.detail && error.detail.orgId && error.detail.identityId) {
+ if (
+ error instanceof UnauthorizedError &&
+ error.detail?.orgId &&
+ error.detail?.identityId &&
+ error.detail?.identityName
+ ) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- actor: { type: ActorType.UNKNOWN_USER, metadata: {} },
+ actor: {
+ type: ActorType.IDENTITY,
+ metadata: {
+ identityId: error.detail.identityId as string,
+ name: error.detail.identityName as string
+ }
+ },
orgId: error.detail.orgId as string,
event: {
type: EventType.LOGIN_IDENTITY_UA_AUTH_FAILED,
metadata: {
clientId: req.body.clientId,
identityId: error.detail.identityId as string,
- reason: error.detail.reason as string,
+ reasonCode: error.detail.reasonCode as string,
message: error.message
}
}
diff --git a/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts b/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts
index 3b46faf9fd..d02de9cc98 100644
--- a/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts
+++ b/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts
@@ -107,7 +107,12 @@ export const identityAliCloudAuthServiceFactory = ({
if (!isAccountAllowed)
throw new UnauthorizedError({
message: "Access denied: Alibaba Cloud account ARN not allowed.",
- detail: { reason: "arn_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "arn_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -128,7 +133,12 @@ export const identityAliCloudAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ identityName: identity.name,
+ orgId: identity.orgId
+ }
});
}
diff --git a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts b/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
index 02c572f61d..69e3f5903a 100644
--- a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
+++ b/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
@@ -163,7 +163,12 @@ export const identityAwsAuthServiceFactory = ({
if (!isAccountAllowed)
throw new UnauthorizedError({
message: "Access denied: AWS account ID not allowed.",
- detail: { reason: "account_id_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "account_id_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -190,7 +195,12 @@ export const identityAwsAuthServiceFactory = ({
throw new UnauthorizedError({
message: `Access denied: AWS principal ARN not allowed. [principal-arn=${formattedArn}]`,
- detail: { reason: "principal_arn_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "principal_arn_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
}
@@ -212,7 +222,12 @@ export const identityAwsAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
diff --git a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts b/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
index 11885c53a8..1196449378 100644
--- a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
+++ b/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
@@ -92,7 +92,12 @@ export const identityAzureAuthServiceFactory = ({
if (azureIdentity.tid !== identityAzureAuth.tenantId)
throw new UnauthorizedError({
message: "Tenant ID mismatch",
- detail: { reason: "tenant_id_mismatch", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "tenant_id_mismatch",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
if (identityAzureAuth.allowedServicePrincipalIds) {
@@ -106,7 +111,12 @@ export const identityAzureAuthServiceFactory = ({
if (!isServicePrincipalAllowed) {
throw new UnauthorizedError({
message: `Service principal '${azureIdentity.oid}' not allowed`,
- detail: { reason: "service_principal_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "service_principal_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
}
@@ -128,7 +138,12 @@ export const identityAzureAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
diff --git a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
index 55b5a319d2..ddab3662d5 100644
--- a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
+++ b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
@@ -113,7 +113,12 @@ export const identityGcpAuthServiceFactory = ({
if (!isServiceAccountAllowed)
throw new UnauthorizedError({
message: "Access denied: GCP service account not allowed.",
- detail: { reason: "service_account_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "service_account_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -132,7 +137,12 @@ export const identityGcpAuthServiceFactory = ({
if (!isProjectAllowed)
throw new UnauthorizedError({
message: "Access denied: GCP project not allowed.",
- detail: { reason: "project_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "project_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -145,7 +155,12 @@ export const identityGcpAuthServiceFactory = ({
if (!isZoneAllowed)
throw new UnauthorizedError({
message: "Access denied: GCP zone not allowed.",
- detail: { reason: "zone_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "zone_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -166,7 +181,12 @@ export const identityGcpAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
diff --git a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
index 87babe43f2..9d1ca61a45 100644
--- a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
+++ b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
@@ -104,7 +104,12 @@ export const identityJwtAuthServiceFactory = ({
if (!decodedToken) {
throw new UnauthorizedError({
message: "Invalid JWT",
- detail: { reason: "invalid_jwt", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "invalid_jwt",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -137,7 +142,12 @@ export const identityJwtAuthServiceFactory = ({
if (error instanceof jwt.JsonWebTokenError) {
throw new UnauthorizedError({
message: `Access denied: ${error.message}`,
- detail: { reason: "jwt_verification_failed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "jwt_verification_failed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -164,7 +174,12 @@ export const identityJwtAuthServiceFactory = ({
if (!isMatchAnyKey) {
throw new UnauthorizedError({
message: `Access denied: JWT verification failed with all keys. Errors - ${errors.join("; ")}`,
- detail: { reason: "jwt_verification_failed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "jwt_verification_failed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
}
@@ -181,7 +196,12 @@ export const identityJwtAuthServiceFactory = ({
if (!tokenData.sub) {
throw new UnauthorizedError({
message: "Access denied: token has no subject field",
- detail: { reason: "missing_subject", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "missing_subject",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -196,7 +216,12 @@ export const identityJwtAuthServiceFactory = ({
if (!tokenData.aud) {
throw new UnauthorizedError({
message: "Access denied: token has no audience field",
- detail: { reason: "missing_audience", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "missing_audience",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -207,7 +232,12 @@ export const identityJwtAuthServiceFactory = ({
) {
throw new UnauthorizedError({
message: "Access denied: token audience not allowed",
- detail: { reason: "audience_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "audience_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
}
@@ -220,7 +250,12 @@ export const identityJwtAuthServiceFactory = ({
if (!value) {
throw new UnauthorizedError({
message: `Access denied: token has no ${claimKey} field`,
- detail: { reason: "missing_claim", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "missing_claim",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -228,7 +263,12 @@ export const identityJwtAuthServiceFactory = ({
if (!claimValue.split(", ").some((claimEntry) => doesFieldValueMatchJwtPolicy(value, claimEntry))) {
throw new UnauthorizedError({
message: `Access denied: claim mismatch for field ${claimKey}`,
- detail: { reason: "claim_mismatch", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "claim_mismatch",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
});
@@ -251,7 +291,12 @@ export const identityJwtAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
index 64ee967b7d..5074348d13 100644
--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
@@ -491,7 +491,12 @@ export const identityKubernetesAuthServiceFactory = ({
throw new UnauthorizedError({
message: data.status.error,
name: "KubernetesTokenReviewError",
- detail: { reason: "token_review_error", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "token_review_error",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
// check the response to determine if the token is valid
@@ -499,7 +504,12 @@ export const identityKubernetesAuthServiceFactory = ({
throw new UnauthorizedError({
message: "Kubernetes token not authenticated",
name: "KubernetesTokenReviewError",
- detail: { reason: "token_not_authenticated", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "token_not_authenticated",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
const { namespace: targetNamespace, name: targetName } = extractK8sUsername(data.status.user.username);
@@ -515,7 +525,12 @@ export const identityKubernetesAuthServiceFactory = ({
if (!isNamespaceAllowed)
throw new UnauthorizedError({
message: "Access denied: K8s namespace not allowed.",
- detail: { reason: "namespace_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "namespace_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -530,7 +545,12 @@ export const identityKubernetesAuthServiceFactory = ({
if (!isNameAllowed)
throw new UnauthorizedError({
message: "Access denied: K8s name not allowed.",
- detail: { reason: "name_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "name_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -543,7 +563,12 @@ export const identityKubernetesAuthServiceFactory = ({
if (!isAudienceAllowed)
throw new UnauthorizedError({
message: "Access denied: K8s audience not allowed.",
- detail: { reason: "audience_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "audience_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -564,7 +589,12 @@ export const identityKubernetesAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
diff --git a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
index 9541da846b..e380cbdc20 100644
--- a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
+++ b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
@@ -199,7 +199,12 @@ export const identityLdapAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -867,7 +872,7 @@ export const identityLdapAuthServiceFactory = ({
if (lockout && lockout?.lockedOut) {
throw new UnauthorizedError({
message: "This identity auth method is temporarily locked, please try again later",
- detail: { reason: "temporarily_locked", identityId, orgId }
+ detail: { reasonCode: "temporarily_locked", identityId, orgId, identityName: identity?.name }
});
}
@@ -887,7 +892,7 @@ export const identityLdapAuthServiceFactory = ({
if (!identityLdapAuth) {
throw new UnauthorizedError({
message: "Invalid credentials",
- detail: { reason: "ldap_auth_not_found", identityId, orgId }
+ detail: { reasonCode: "ldap_auth_not_found", identityId, orgId, identityName: identity?.name }
});
}
@@ -914,7 +919,7 @@ export const identityLdapAuthServiceFactory = ({
if (lockout.lockedOut) {
throw new UnauthorizedError({
message: "This identity auth method is temporarily locked, please try again later",
- detail: { reason: "temporarily_locked", identityId, orgId }
+ detail: { reasonCode: "temporarily_locked", identityId, orgId, identityName: identity?.name }
});
}
@@ -945,7 +950,7 @@ export const identityLdapAuthServiceFactory = ({
throw new UnauthorizedError({
message: "Invalid credentials",
- detail: { reason: "invalid_credentials", identityId, orgId }
+ detail: { reasonCode: "invalid_credentials", identityId, orgId, identityName: identity?.name }
});
}
throw error;
diff --git a/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts b/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts
index c57df66c8e..0ecfee6972 100644
--- a/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts
+++ b/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts
@@ -104,7 +104,12 @@ export const identityOciAuthServiceFactory = ({
if (data.compartmentId !== identityOciAuth.tenancyOcid) {
throw new UnauthorizedError({
message: "Access denied: OCI account isn't part of tenancy.",
- detail: { reason: "tenancy_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "tenancy_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -114,7 +119,12 @@ export const identityOciAuthServiceFactory = ({
if (!isAccountAllowed)
throw new UnauthorizedError({
message: "Access denied: OCI account username not allowed.",
- detail: { reason: "username_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "username_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -135,7 +145,12 @@ export const identityOciAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
diff --git a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
index 74546be219..a6f5daeaf0 100644
--- a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
+++ b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
@@ -120,7 +120,12 @@ export const identityOidcAuthServiceFactory = ({
} catch (error) {
throw new UnauthorizedError({
message: `Access denied: Failed to fetch OIDC discovery document from ${identityOidcAuth.oidcDiscoveryUrl}. ${error instanceof Error ? error.message : String(error)}`,
- detail: { reason: "discovery_document_fetch_failed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "discovery_document_fetch_failed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -128,7 +133,12 @@ export const identityOidcAuthServiceFactory = ({
if (!jwksUri) {
throw new UnauthorizedError({
message: `Access denied: OIDC discovery document does not contain a jwks_uri. The identity provider may be misconfigured.`,
- detail: { reason: "missing_jwks_uri", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "missing_jwks_uri",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -136,7 +146,12 @@ export const identityOidcAuthServiceFactory = ({
if (!decodedToken) {
throw new UnauthorizedError({
message: "Invalid JWT",
- detail: { reason: "invalid_jwt", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "invalid_jwt",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -158,12 +173,22 @@ export const identityOidcAuthServiceFactory = ({
if (error instanceof Error && error.name === "SigningKeyNotFoundError") {
throw new UnauthorizedError({
message: `Access denied: Unable to verify JWT signature. The signing key '${kid}' was not found in the OIDC provider's JWKS endpoint. This may indicate an invalid token or misconfigured OIDC provider.`,
- detail: { reason: "signing_key_not_found", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "signing_key_not_found",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
throw new UnauthorizedError({
message: `Access denied: Failed to retrieve signing key from OIDC provider: ${error instanceof Error ? error.message : String(error)}`,
- detail: { reason: "signing_key_retrieval_failed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "signing_key_retrieval_failed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -175,7 +200,12 @@ export const identityOidcAuthServiceFactory = ({
if (error instanceof jwt.JsonWebTokenError) {
throw new UnauthorizedError({
message: `Access denied: ${error.message}`,
- detail: { reason: "jwt_verification_failed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "jwt_verification_failed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
throw error;
@@ -192,14 +222,24 @@ export const identityOidcAuthServiceFactory = ({
} catch (error) {
throw new UnauthorizedError({
message: `Access denied: Failed to retrieve signing keys from OIDC provider: ${error instanceof Error ? error.message : String(error)}`,
- detail: { reason: "signing_keys_retrieval_failed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "signing_keys_retrieval_failed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
if (!allSigningKeys || allSigningKeys.length === 0) {
throw new UnauthorizedError({
message: "Access denied: No signing keys available from OIDC provider's JWKS endpoint.",
- detail: { reason: "no_signing_keys", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "no_signing_keys",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -208,7 +248,12 @@ export const identityOidcAuthServiceFactory = ({
if (allSigningKeys.length > MAX_KEYS_TO_TRY) {
throw new UnauthorizedError({
message: `Access denied: OIDC provider has ${allSigningKeys.length} signing keys. Tokens must include 'kid' header when provider has more than ${MAX_KEYS_TO_TRY} keys.`,
- detail: { reason: "too_many_signing_keys", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "too_many_signing_keys",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -236,7 +281,12 @@ export const identityOidcAuthServiceFactory = ({
if (!verified) {
throw new UnauthorizedError({
message: `Access denied: Unable to verify JWT signature with any available signing key. ${lastError ? lastError.message : "Invalid token"}`,
- detail: { reason: "jwt_verification_failed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "jwt_verification_failed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
}
@@ -245,7 +295,12 @@ export const identityOidcAuthServiceFactory = ({
if (!tokenData) {
throw new UnauthorizedError({
message: "Access denied: Failed to verify JWT token",
- detail: { reason: "jwt_verification_failed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "jwt_verification_failed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -267,7 +322,12 @@ export const identityOidcAuthServiceFactory = ({
) {
throw new UnauthorizedError({
message: "Access denied: OIDC audience not allowed.",
- detail: { reason: "audience_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "audience_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
}
@@ -280,7 +340,12 @@ export const identityOidcAuthServiceFactory = ({
if (!value) {
throw new UnauthorizedError({
message: `Access denied: token has no ${claimKey} field`,
- detail: { reason: "missing_claim", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "missing_claim",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -288,7 +353,12 @@ export const identityOidcAuthServiceFactory = ({
if (!claimValue.split(", ").some((claimEntry) => doesFieldValueMatchOidcPolicy(value, claimEntry))) {
throw new UnauthorizedError({
message: "Access denied: OIDC claim not allowed.",
- detail: { reason: "claim_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "claim_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
});
@@ -302,7 +372,12 @@ export const identityOidcAuthServiceFactory = ({
if (!value) {
throw new UnauthorizedError({
message: `Access denied: token has no ${claimKey} field`,
- detail: { reason: "missing_metadata_claim", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "missing_metadata_claim",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
filteredClaims[permissionKey] = value.toString();
@@ -326,7 +401,12 @@ export const identityOidcAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
diff --git a/backend/src/services/identity-spiffe-auth/identity-spiffe-auth-service.ts b/backend/src/services/identity-spiffe-auth/identity-spiffe-auth-service.ts
index 324f0c2574..d76dee8439 100644
--- a/backend/src/services/identity-spiffe-auth/identity-spiffe-auth-service.ts
+++ b/backend/src/services/identity-spiffe-auth/identity-spiffe-auth-service.ts
@@ -325,9 +325,10 @@ export const identitySpiffeAuthServiceFactory = ({
} catch (retryError) {
if (retryError instanceof UnauthorizedError) {
retryError.detail = {
- reason: "jwt_svid_verification_failed",
+ reasonCode: "jwt_svid_verification_failed",
identityId: identity.id,
- orgId: identity.orgId
+ orgId: identity.orgId,
+ identityName: identity.name
};
}
throw retryError;
@@ -335,9 +336,10 @@ export const identitySpiffeAuthServiceFactory = ({
} else {
if (verifyError instanceof UnauthorizedError) {
verifyError.detail = {
- reason: "jwt_svid_verification_failed",
+ reasonCode: "jwt_svid_verification_failed",
identityId: identity.id,
- orgId: identity.orgId
+ orgId: identity.orgId,
+ identityName: identity.name
};
}
throw verifyError;
@@ -347,7 +349,12 @@ export const identitySpiffeAuthServiceFactory = ({
if (!validateSpiffeClaims(tokenData, identitySpiffeAuth)) {
throw new UnauthorizedError({
message: "Access denied",
- detail: { reason: "spiffe_claims_invalid", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "spiffe_claims_invalid",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -368,7 +375,12 @@ export const identitySpiffeAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
diff --git a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
index 64c168eebd..547ba01104 100644
--- a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
+++ b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
@@ -115,20 +115,35 @@ export const identityTlsCertAuthServiceFactory = ({
if (!isValidCertificate)
throw new UnauthorizedError({
message: "Access denied: Certificate not issued by the provided CA.",
- detail: { reason: "ca_verification_failed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "ca_verification_failed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
if (new Date(clientCertificateX509.validTo) < new Date()) {
throw new UnauthorizedError({
message: "Access denied: Certificate has expired.",
- detail: { reason: "certificate_expired", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "certificate_expired",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
if (new Date(clientCertificateX509.validFrom) > new Date()) {
throw new UnauthorizedError({
message: "Access denied: Certificate not yet valid.",
- detail: { reason: "certificate_not_yet_valid", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "certificate_not_yet_valid",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -138,7 +153,12 @@ export const identityTlsCertAuthServiceFactory = ({
if (!isValidCommonName) {
throw new UnauthorizedError({
message: "Access denied: TLS Certificate Auth common name not allowed.",
- detail: { reason: "common_name_not_allowed", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "common_name_not_allowed",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
}
@@ -160,7 +180,12 @@ export const identityTlsCertAuthServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identity.id, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identity.id,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.ts
index 01ede2f06e..ec9b4719e4 100644
--- a/backend/src/services/identity-ua/identity-ua-service.ts
+++ b/backend/src/services/identity-ua/identity-ua-service.ts
@@ -86,7 +86,7 @@ export const identityUaServiceFactory = ({
if (!identityUa) {
throw new UnauthorizedError({
message: "Invalid credentials",
- detail: { reason: "client_id_not_found", identityId: null }
+ detail: { reasonCode: "client_id_not_found" }
});
}
@@ -115,7 +115,12 @@ export const identityUaServiceFactory = ({
if (lockout && lockout.lockedOut) {
throw new UnauthorizedError({
message: "This identity auth method is temporarily locked, please try again later",
- detail: { reason: "temporarily_locked", identityId: identityUa.identityId, orgId: identity.orgId }
+ detail: {
+ reasonCode: "temporarily_locked",
+ identityId: identityUa.identityId,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -160,7 +165,12 @@ export const identityUaServiceFactory = ({
if (lockout.lockedOut) {
throw new UnauthorizedError({
message: "This identity auth method is temporarily locked, please try again later",
- detail: { reason: "temporarily_locked", identityId: identityUa.identityId, orgId: identity.orgId }
+ detail: {
+ reasonCode: "temporarily_locked",
+ identityId: identityUa.identityId,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
@@ -191,7 +201,12 @@ export const identityUaServiceFactory = ({
throw new UnauthorizedError({
message: "Invalid credentials",
- detail: { reason: "invalid_client_secret", identityId: identityUa.identityId, orgId: identity.orgId }
+ detail: {
+ reasonCode: "invalid_client_secret",
+ identityId: identityUa.identityId,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
} else if (lockout) {
// If credentials are valid, clear any existing lockout record
@@ -212,7 +227,12 @@ export const identityUaServiceFactory = ({
throw new UnauthorizedError({
message: "Access denied due to expired client secret",
- detail: { reason: "client_secret_expired", identityId: identityUa.identityId, orgId: identity.orgId }
+ detail: {
+ reasonCode: "client_secret_expired",
+ identityId: identityUa.identityId,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}
}
@@ -226,9 +246,10 @@ export const identityUaServiceFactory = ({
throw new UnauthorizedError({
message: "Access denied due to client secret usage limit reached",
detail: {
- reason: "client_secret_usage_limit_reached",
+ reasonCode: "client_secret_usage_limit_reached",
identityId: identityUa.identityId,
- orgId: identity.orgId
+ orgId: identity.orgId,
+ identityName: identity.name
}
});
}
@@ -264,7 +285,12 @@ export const identityUaServiceFactory = ({
if (!subOrgMembership) {
throw new UnauthorizedError({
message: `Identity not authorized to access sub organization ${organizationSlug}`,
- detail: { reason: "sub_org_unauthorized", identityId: identityUa.identityId, orgId: identity.orgId }
+ detail: {
+ reasonCode: "sub_org_unauthorized",
+ identityId: identityUa.identityId,
+ orgId: identity.orgId,
+ identityName: identity.name
+ }
});
}