AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(audit-logs): record who changed an authentication setting (ENG-495) (#16867)
lina-alomari4bc37aa67925
diff --git a/packages/core/shared/package.json b/packages/core/shared/package.jsonindex a61e76d1e5d..e196e26c389 100644--- a/packages/core/shared/package.json+++ b/packages/core/shared/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/shared",- "version": "0.208.1",+ "version": "0.209.0","type": "commonjs","sideEffects": false,"main": "./dist/src/index.js",diff --git a/packages/core/shared/src/lib/ee/audit-events/index.ts b/packages/core/shared/src/lib/ee/audit-events/index.tsindex 648f5f44dbe..b1799ea0050 100644--- a/packages/core/shared/src/lib/ee/audit-events/index.ts+++ b/packages/core/shared/src/lib/ee/audit-events/index.ts@@ -52,6 +52,22 @@ export enum ApplicationEventName {USER_EMAIL_VERIFIED = 'user.email.verified',SIGNING_KEY_CREATED = 'signing.key.created',AUDIT_LOG_RETENTION_UPDATED = 'audit.log.retention.updated',+ EMAIL_SIGN_IN_ENABLED = 'authentication.email.enabled',+ EMAIL_SIGN_IN_DISABLED = 'authentication.email.disabled',+ GOOGLE_SIGN_IN_ENABLED = 'authentication.google.enabled',+ GOOGLE_SIGN_IN_DISABLED = 'authentication.google.disabled',+ ALLOWED_DOMAIN_ADDED = 'authentication.allowed.domain.added',+ ALLOWED_DOMAIN_REMOVED = 'authentication.allowed.domain.removed',+ ALLOWED_DOMAIN_ENFORCEMENT_ENABLED = 'authentication.allowed.domain.enforcement.enabled',+ ALLOWED_DOMAIN_ENFORCEMENT_DISABLED = 'authentication.allowed.domain.enforcement.disabled',+ SSO_DOMAIN_ADDED = 'sso.domain.added',+ SSO_DOMAIN_VERIFIED = 'sso.domain.verified',+ SSO_DOMAIN_VERIFICATION_CANCELLED = 'sso.domain.verification.cancelled',+ SSO_DOMAIN_REMOVED = 'sso.domain.removed',+ SSO_DOMAIN_EXPIRED = 'sso.domain.expired',+ SAML_CONNECTED = 'sso.saml.connected',+ SAML_CONNECTION_REPLACED = 'sso.saml.replaced',+ SSO_DISABLED = 'sso.saml.disabled',PROJECT_ROLE_CREATED = 'project.role.created',PROJECT_ROLE_DELETED = 'project.role.deleted',PROJECT_ROLE_UPDATED = 'project.role.updated',@@ -532,6 +548,42 @@ export const AuditLogRetentionUpdatedEvent = z.object({export type AuditLogRetentionUpdatedEvent = z.infer<typeof AuditLogRetentionUpdatedEvent>+export const AuthenticationSettingEvent = z.object({+ ...BaseAuditEventProps,+ action: z.union([+ z.literal(ApplicationEventName.EMAIL_SIGN_IN_ENABLED),+ z.literal(ApplicationEventName.EMAIL_SIGN_IN_DISABLED),+ z.literal(ApplicationEventName.GOOGLE_SIGN_IN_ENABLED),+ z.literal(ApplicationEventName.GOOGLE_SIGN_IN_DISABLED),+ z.literal(ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED),+ z.literal(ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED),+ z.literal(ApplicationEventName.SAML_CONNECTED),+ z.literal(ApplicationEventName.SAML_CONNECTION_REPLACED),+ z.literal(ApplicationEventName.SSO_DISABLED),+ ]),+ data: z.object({}),+})++export type AuthenticationSettingEvent = z.infer<typeof AuthenticationSettingEvent>++export const AuthenticationDomainEvent = z.object({+ ...BaseAuditEventProps,+ action: z.union([+ z.literal(ApplicationEventName.ALLOWED_DOMAIN_ADDED),+ z.literal(ApplicationEventName.ALLOWED_DOMAIN_REMOVED),+ z.literal(ApplicationEventName.SSO_DOMAIN_ADDED),+ z.literal(ApplicationEventName.SSO_DOMAIN_VERIFIED),+ z.literal(ApplicationEventName.SSO_DOMAIN_VERIFICATION_CANCELLED),+ z.literal(ApplicationEventName.SSO_DOMAIN_REMOVED),+ z.literal(ApplicationEventName.SSO_DOMAIN_EXPIRED),+ ]),+ data: z.object({+ domain: z.string(),+ }),+})++export type AuthenticationDomainEvent = z.infer<typeof AuthenticationDomainEvent>+export const ProjectRoleEvent = z.object({...BaseAuditEventProps,action: z.union([@@ -649,6 +701,8 @@ export const ApplicationEvent = z.union([SignUpEvent,SigningKeyEvent,AuditLogRetentionUpdatedEvent,+ AuthenticationSettingEvent,+ AuthenticationDomainEvent,ProjectRoleEvent,ProjectReleaseEvent,ProjectReplacedEvent,@@ -740,6 +794,38 @@ export function summarizeApplicationEvent(event: ApplicationEvent) {const next = describeAuditLogRetention({ days: retentionDays, instanceLimitDays })return `Audit log retention changed from ${previous} to ${next}`}+ case ApplicationEventName.EMAIL_SIGN_IN_ENABLED:+ return 'Email and password sign-in turned on'+ case ApplicationEventName.EMAIL_SIGN_IN_DISABLED:+ return 'Email and password sign-in turned off'+ case ApplicationEventName.GOOGLE_SIGN_IN_ENABLED:+ return 'Google sign-in turned on'+ case ApplicationEventName.GOOGLE_SIGN_IN_DISABLED:+ return 'Google sign-in turned off'+ case ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED:+ return 'Only allowed email domains can join or sign in with email and password'+ case ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED:+ return 'Any email domain can join or sign in with email and password'+ case ApplicationEventName.ALLOWED_DOMAIN_ADDED:+ return `${event.data.domain} added to allowed email domains`+ case ApplicationEventName.ALLOWED_DOMAIN_REMOVED:+ return `${event.data.domain} removed from allowed email domains`+ case ApplicationEventName.SSO_DOMAIN_ADDED:+ return `${event.data.domain} added, waiting for DNS verification`+ case ApplicationEventName.SSO_DOMAIN_VERIFIED:+ return `${event.data.domain} verified`+ case ApplicationEventName.SSO_DOMAIN_VERIFICATION_CANCELLED:+ return `Verification of ${event.data.domain} cancelled`+ case ApplicationEventName.SSO_DOMAIN_REMOVED:+ return `${event.data.domain} removed`+ case ApplicationEventName.SSO_DOMAIN_EXPIRED:+ return `${event.data.domain} removed because it was not verified in time`+ case ApplicationEventName.SAML_CONNECTED:+ return 'SAML identity provider connected'+ case ApplicationEventName.SAML_CONNECTION_REPLACED:+ return 'SAML identity provider connection replaced'+ case ApplicationEventName.SSO_DISABLED:+ return 'Single sign-on disabled'case ApplicationEventName.PROJECT_ROLE_CREATED:return `${event.data.projectRole.name} is created`case ApplicationEventName.PROJECT_ROLE_UPDATED:diff --git a/packages/core/shared/src/lib/ee/audit-events/mock-event-builder.ts b/packages/core/shared/src/lib/ee/audit-events/mock-event-builder.tsindex 32df9837c3d..8f34c875147 100644--- a/packages/core/shared/src/lib/ee/audit-events/mock-event-builder.ts+++ b/packages/core/shared/src/lib/ee/audit-events/mock-event-builder.ts@@ -8,7 +8,9 @@ import {ApplicationEvent,ApplicationEventName,AuditLogRetentionUpdatedEvent,+ AuthenticationDomainEvent,AuthenticationEvent,+ AuthenticationSettingEvent,ConnectionEvent,FlowActivatedEvent,FlowApprovalEvent,@@ -306,6 +308,36 @@ export const buildMockEvent = ({ event, platformId, projectId }: BuildMockEventP}return mock}+ case ApplicationEventName.EMAIL_SIGN_IN_ENABLED:+ case ApplicationEventName.EMAIL_SIGN_IN_DISABLED:+ case ApplicationEventName.GOOGLE_SIGN_IN_ENABLED:+ case ApplicationEventName.GOOGLE_SIGN_IN_DISABLED:+ case ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED:+ case ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED:+ case ApplicationEventName.SAML_CONNECTED:+ case ApplicationEventName.SAML_CONNECTION_REPLACED:+ case ApplicationEventName.SSO_DISABLED: {+ const mock: AuthenticationSettingEvent = {+ ...baseEnvelope,+ action: event,+ data: {},+ }+ return mock+ }+ case ApplicationEventName.ALLOWED_DOMAIN_ADDED:+ case ApplicationEventName.ALLOWED_DOMAIN_REMOVED:+ case ApplicationEventName.SSO_DOMAIN_ADDED:+ case ApplicationEventName.SSO_DOMAIN_VERIFIED:+ case ApplicationEventName.SSO_DOMAIN_VERIFICATION_CANCELLED:+ case ApplicationEventName.SSO_DOMAIN_REMOVED:+ case ApplicationEventName.SSO_DOMAIN_EXPIRED: {+ const mock: AuthenticationDomainEvent = {+ ...baseEnvelope,+ action: event,+ data: { domain: 'acme.com' },+ }+ return mock+ }case ApplicationEventName.PROJECT_ROLE_CREATED:case ApplicationEventName.PROJECT_ROLE_UPDATED:case ApplicationEventName.PROJECT_ROLE_DELETED: {diff --git a/packages/server/api/src/app/authentication/authentication-utils.ts b/packages/server/api/src/app/authentication/authentication-utils.tsindex b86b3d91b55..965796e1e5f 100644--- a/packages/server/api/src/app/authentication/authentication-utils.ts+++ b/packages/server/api/src/app/authentication/authentication-utils.ts@@ -143,7 +143,7 @@ export const authenticationUtils = (log: FastifyBaseLogger) => ({const emailDomain = email.split('@')[1]const isAllowedDomaiin =!platform.enforceAllowedAuthDomains ||- platform.allowedAuthDomains.includes(emailDomain)+ platform.allowedAuthDomains.some((domain) => domain.toLowerCase() === emailDomain?.toLowerCase())if (!isAllowedDomaiin) {throw new ActivepiecesError({diff --git a/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-controller.ts b/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-controller.tsindex 8cc16f2f2d3..d2729dc1648 100644--- a/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-controller.ts+++ b/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-controller.ts@@ -67,12 +67,16 @@ export const authnSsoSamlController: FastifyPluginAsyncZod = async (app) => {return authnSsoSamlService(req.log).updateSsoDomain({platformId: req.principal.platform.id,ssoDomain: req.body.ssoDomain,+ userId: req.principal.id,+ ip: networkUtils.clientIp(req),})})app.post('/sso-domain/verify', VerifySsoDomainRequest, async (req) => {return authnSsoSamlService(req.log).verifySsoDomain({platformId: req.principal.platform.id,+ userId: req.principal.id,+ ip: networkUtils.clientIp(req),})})}diff --git a/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-service.ts b/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-service.tsindex c8c9065e512..491f8aa29ac 100644--- a/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-service.ts+++ b/packages/server/api/src/app/ee/authentication/saml-authn/authn-sso-saml-service.ts@@ -1,11 +1,12 @@import { resolveTxt } from 'dns/promises'-import { ActivepiecesError, apId, assertNotNullOrUndefined, ErrorCode, isNil, PlatformId, spreadIfDefined, tryCatch } from '@activepieces/core-utils'+import { ActivepiecesError, apId, assertNotNullOrUndefined, ErrorCode, isNil, PlatformId, spreadIfDefined, tryCatch, UserId } from '@activepieces/core-utils'import { ApEdition, AuthenticationResponse, SAMLAuthnProviderConfig, SsoDomainVerification, SsoDomainVerificationRecordType, SsoDomainVerificationStatus, UserIdentityProvider } from '@activepieces/shared'import { FastifyBaseLogger } from 'fastify'import { z } from 'zod'import { authenticationService } from '../../../authentication/authentication.service'import { domainHelper } from '../../../helper/domain-helper'import { system } from '../../../helper/system/system'+import { platformSideEffects } from '../../../platform/platform-side-effects'import { platformRepo, platformService } from '../../../platform/platform.service'import { platformUtils } from '../../../platform/platform.utils'import { platformPlanService } from '../../platform/platform-plan/platform-plan.service'@@ -78,7 +79,7 @@ export const authnSsoSamlService = (log: FastifyBaseLogger) => {}return { platformId: platform.id }},- async updateSsoDomain({ platformId, ssoDomain }: UpdateSsoDomainParams): Promise<SsoDomainState> {+ async updateSsoDomain({ platformId, ssoDomain, userId, ip }: UpdateSsoDomainParams): Promise<SsoDomainState> {const normalized = ssoDomain?.trim().toLowerCase() ?? nullconst value = normalized && normalized.length > 0 ? normalized : nullif (!isNil(value)) {@@ -111,10 +112,12 @@ export const authnSsoSamlService = (log: FastifyBaseLogger) => {ssoDomain: value,ssoDomainVerification: verification,...spreadIfDefined('federatedAuthProviders', removesSaml ? { saml: null } : undefined),+ userId,+ ip,})return { ssoDomain: value, ssoDomainVerification: verification }},- async verifySsoDomain({ platformId }: VerifySsoDomainParams): Promise<SsoDomainState> {+ async verifySsoDomain({ platformId, userId, ip }: VerifySsoDomainParams): Promise<SsoDomainState> {const platform = await platformService(log).getOneOrThrow(platformId)if (isNil(platform.ssoDomain) || isNil(platform.ssoDomainVerification)) {throw new ActivepiecesError({@@ -137,21 +140,32 @@ export const authnSsoSamlService = (log: FastifyBaseLogger) => {...platform.ssoDomainVerification,status: SsoDomainVerificationStatus.VERIFIED,}- const updated = await platformService(log).update({ id: platformId, ssoDomainVerification: verified })+ const updated = await platformService(log).update({ id: platformId, ssoDomainVerification: verified, userId, ip })return { ssoDomain: updated.ssoDomain ?? null, ssoDomainVerification: updated.ssoDomainVerification ?? null }},async expirePendingSsoDomains(): Promise<void> {- const result = await platformRepo()- .createQueryBuilder()- .update()- .set({ ssoDomain: null, ssoDomainVerification: null })- .where('"ssoDomain" IS NOT NULL')- .andWhere('"ssoDomainVerification"->>\'status\' = :status', { status: SsoDomainVerificationStatus.PENDING_VERIFICATION })- .andWhere(`("ssoDomainVerification"->>'createdAt')::timestamptz < NOW() - INTERVAL '${PENDING_DOMAIN_TTL_DAYS} day'`)- .execute()- const affected = result.affected ?? 0- if (affected > 0) {- log.info({ affected }, 'Expired pending SSO domain verifications')+ const rows: unknown = await platformRepo().query(`+ WITH expired AS (+ SELECT id, "ssoDomain" FROM "platform"+ WHERE "ssoDomain" IS NOT NULL+ AND "ssoDomainVerification"->>'status' = $1+ AND ("ssoDomainVerification"->>'createdAt')::timestamptz < NOW() - make_interval(days => $2)+ FOR UPDATE SKIP LOCKED+ ), cleared AS (+ UPDATE "platform" p+ SET "ssoDomain" = NULL, "ssoDomainVerification" = NULL+ FROM expired+ WHERE p.id = expired.id+ RETURNING p.id AS "platformId", expired."ssoDomain" AS "domain"+ )+ SELECT "platformId", "domain" FROM cleared+ `, [SsoDomainVerificationStatus.PENDING_VERIFICATION, PENDING_DOMAIN_TTL_DAYS])+ const expired = ExpiredSsoDomainRows.parse(rows)+ for (const { platformId, domain } of expired) {+ platformSideEffects(log).onSsoDomainExpired({ platformId, domain })+ }+ if (expired.length > 0) {+ log.info({ affected: expired.length }, 'Expired pending SSO domain verifications')}},}@@ -159,6 +173,11 @@ export const authnSsoSamlService = (log: FastifyBaseLogger) => {const PENDING_DOMAIN_TTL_DAYS = 7+const ExpiredSsoDomainRows = z.array(z.object({+ platformId: z.string(),+ domain: z.string(),+}))+function computeNextVerification({ nextDomain, currentDomain, currentVerification }: { nextDomain: string | null, currentDomain: string | null, currentVerification: SsoDomainVerification | null }): SsoDomainVerification | null {if (isNil(nextDomain)) {return null@@ -205,10 +224,14 @@ type DiscoverResult = {type UpdateSsoDomainParams = {platformId: PlatformIdssoDomain: string | null+ userId: UserId+ ip: string}type VerifySsoDomainParams = {platformId: PlatformId+ userId: UserId+ ip: string}type SsoDomainState = {diff --git a/packages/server/api/src/app/platform/authentication-audit-events.ts b/packages/server/api/src/app/platform/authentication-audit-events.tsnew file mode 100644index 00000000000..00e96767fee--- /dev/null+++ b/packages/server/api/src/app/platform/authentication-audit-events.ts@@ -0,0 +1,104 @@+import { isNil } from '@activepieces/core-utils'+import { ApplicationEventName, AuthenticationDomainEvent, AuthenticationSettingEvent, Platform, PlatformWithoutFederatedAuth, SAMLAuthnProviderConfig, SsoDomainVerificationStatus } from '@activepieces/shared'+import deepEqual from 'deep-equal'++function buildAuthenticationEvents({ before, after }: AuthenticationEventsParams): AuthenticationAuditEventParams[] {+ return [+ ...toggleEvents({+ previous: before.emailAuthEnabled,+ next: after.emailAuthEnabled,+ enabledAction: ApplicationEventName.EMAIL_SIGN_IN_ENABLED,+ disabledAction: ApplicationEventName.EMAIL_SIGN_IN_DISABLED,+ }),+ ...toggleEvents({+ previous: before.googleAuthEnabled,+ next: after.googleAuthEnabled,+ enabledAction: ApplicationEventName.GOOGLE_SIGN_IN_ENABLED,+ disabledAction: ApplicationEventName.GOOGLE_SIGN_IN_DISABLED,+ }),+ ...allowedDomainEvents({ before, after }),+ ...toggleEvents({+ previous: before.enforceAllowedAuthDomains,+ next: after.enforceAllowedAuthDomains,+ enabledAction: ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED,+ disabledAction: ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED,+ }),+ ...ssoDomainEvents({ before, after }),+ ...samlEvents({ before, after }),+ ]+}++function toggleEvents({ previous, next, enabledAction, disabledAction }: ToggleEventsParams): AuthenticationAuditEventParams[] {+ if (previous === next) {+ return []+ }+ return [{ action: next ? enabledAction : disabledAction, data: {} }]+}++function allowedDomainEvents({ before, after }: AuthenticationEventsParams): AuthenticationAuditEventParams[] {+ const previous = before.allowedAuthDomains.map((domain) => domain.toLowerCase())+ const next = after.allowedAuthDomains.map((domain) => domain.toLowerCase())+ const added = after.allowedAuthDomains.filter((domain) => !previous.includes(domain.toLowerCase()))+ const removed = before.allowedAuthDomains.filter((domain) => !next.includes(domain.toLowerCase()))+ return [+ ...added.map((domain): AuthenticationAuditEventParams => ({ action: ApplicationEventName.ALLOWED_DOMAIN_ADDED, data: { domain } })),+ ...removed.map((domain): AuthenticationAuditEventParams => ({ action: ApplicationEventName.ALLOWED_DOMAIN_REMOVED, data: { domain } })),+ ]+}++function ssoDomainEvents({ before, after }: AuthenticationEventsParams): AuthenticationAuditEventParams[] {+ const previousDomain = before.ssoDomain ?? null+ const nextDomain = after.ssoDomain ?? null+ const wasVerified = before.ssoDomainVerification?.status === SsoDomainVerificationStatus.VERIFIED+ const isVerified = after.ssoDomainVerification?.status === SsoDomainVerificationStatus.VERIFIED+ if (previousDomain === nextDomain) {+ const justVerified = !isNil(nextDomain) && !wasVerified && isVerified+ return justVerified ? [{ action: ApplicationEventName.SSO_DOMAIN_VERIFIED, data: { domain: nextDomain } }] : []+ }+ const removed: AuthenticationAuditEventParams[] = isNil(previousDomain)+ ? []+ : [{ action: wasVerified ? ApplicationEventName.SSO_DOMAIN_REMOVED : ApplicationEventName.SSO_DOMAIN_VERIFICATION_CANCELLED, data: { domain: previousDomain } }]+ const added: AuthenticationAuditEventParams[] = isNil(nextDomain)+ ? []+ : [{ action: ApplicationEventName.SSO_DOMAIN_ADDED, data: { domain: nextDomain } }]+ return [...removed, ...added]+}++function samlEvents({ before, after }: AuthenticationEventsParams): AuthenticationAuditEventParams[] {+ const previous = readSaml(before)+ const next = readSaml(after)+ if (previous === undefined || next === undefined || deepEqual(previous, next)) {+ return []+ }+ if (isNil(previous)) {+ return [{ action: ApplicationEventName.SAML_CONNECTED, data: {} }]+ }+ if (isNil(next)) {+ return [{ action: ApplicationEventName.SSO_DISABLED, data: {} }]+ }+ return [{ action: ApplicationEventName.SAML_CONNECTION_REPLACED, data: {} }]+}++function readSaml(platform: AuthenticationEventsPlatform): SAMLAuthnProviderConfig | null | undefined {+ return 'federatedAuthProviders' in platform ? platform.federatedAuthProviders?.saml ?? null : undefined+}++export const authenticationAuditEvents = {+ build: buildAuthenticationEvents,+}++type AuthenticationEventsPlatform = Platform | PlatformWithoutFederatedAuth++type AuthenticationEventsParams = {+ before: AuthenticationEventsPlatform+ after: AuthenticationEventsPlatform+}++type ToggleEventsParams = {+ previous: boolean+ next: boolean+ enabledAction: AuthenticationSettingEvent['action']+ disabledAction: AuthenticationSettingEvent['action']+}++export type AuthenticationAuditEventParams = Pick<AuthenticationSettingEvent, 'action' | 'data'> | Pick<AuthenticationDomainEvent, 'action' | 'data'>diff --git a/packages/server/api/src/app/platform/platform-side-effects.ts b/packages/server/api/src/app/platform/platform-side-effects.tsindex 6dadb5d4758..192bd009d75 100644--- a/packages/server/api/src/app/platform/platform-side-effects.ts+++ b/packages/server/api/src/app/platform/platform-side-effects.ts@@ -2,6 +2,7 @@ import { PlatformId, UserId } from '@activepieces/core-utils'import { ApplicationEventName } from '@activepieces/shared'import { FastifyBaseLogger } from 'fastify'import { applicationEvents } from '../helper/application-events'+import { AuthenticationAuditEventParams } from './authentication-audit-events'export const platformSideEffects = (log: FastifyBaseLogger) => ({onAuditLogRetentionUpdated({ platformId, userId, ip, previousRetentionDays, retentionDays, instanceLimitDays }: OnAuditLogRetentionUpdatedParams): void {@@ -14,6 +15,17 @@ export const platformSideEffects = (log: FastifyBaseLogger) => ({},})},+ onAuthenticationSettingsChanged({ platformId, userId, ip, events }: OnAuthenticationSettingsChangedParams): void {+ for (const event of events) {+ applicationEvents(log).sendUserEvent({ platformId, userId, ip }, event)+ }+ },+ onSsoDomainExpired({ platformId, domain }: OnSsoDomainExpiredParams): void {+ applicationEvents(log).sendUserEvent({ platformId }, {+ action: ApplicationEventName.SSO_DOMAIN_EXPIRED,+ data: { domain },+ })+ },})type OnAuditLogRetentionUpdatedParams = {@@ -24,3 +36,15 @@ type OnAuditLogRetentionUpdatedParams = {retentionDays: number | nullinstanceLimitDays: number | null}++type OnAuthenticationSettingsChangedParams = {+ platformId: PlatformId+ userId?: UserId+ ip?: string+ events: AuthenticationAuditEventParams[]+}++type OnSsoDomainExpiredParams = {+ platformId: PlatformId+ domain: string+}diff --git a/packages/server/api/src/app/platform/platform.service.ts b/packages/server/api/src/app/platform/platform.service.tsindex af2a26211cb..13abd5cc36b 100644--- a/packages/server/api/src/app/platform/platform.service.ts+++ b/packages/server/api/src/app/platform/platform.service.ts@@ -17,6 +17,7 @@ import { system } from '../helper/system/system'import { telemetry } from '../helper/telemetry.utils'import { projectService } from '../project/project-service'import { userService } from '../user/user-service'+import { authenticationAuditEvents } from './authentication-audit-events'import { billingProvider } from './billing-provider'import { platformSideEffects } from './platform-side-effects'import { PlatformEntity } from './platform.entity'@@ -213,14 +214,15 @@ export const platformService = (log: FastifyBaseLogger) => ({invalidateSamlClientCache(params.id)}log.info({ platform: { id: params.id } }, 'Platform updated')- const { saved, previousRetentionDays } = await transaction(async (entityManager) => {- const lockedRetentionDays = await lockAuditLogRetentionDays({ entityManager, platformId: params.id })+ const { saved, locked } = await transaction(async (entityManager) => {+ const lockedPlatform = await lockPlatformForUpdate({ entityManager, platformId: params.id, includeFederatedAuth: hasFederatedAuth(platform) })const savedPlatform = await platformRepo(entityManager).save({...updatedPlatform,- auditLogRetentionDays: params.auditLogRetentionDays === undefined ? lockedRetentionDays : params.auditLogRetentionDays,+ auditLogRetentionDays: params.auditLogRetentionDays === undefined ? lockedPlatform.auditLogRetentionDays ?? null : params.auditLogRetentionDays,})- return { saved: savedPlatform, previousRetentionDays: lockedRetentionDays }+ return { saved: savedPlatform, locked: lockedPlatform }})+ const previousRetentionDays = locked.auditLogRetentionDays ?? nullif (params.auditLogRetentionDays !== undefined && params.auditLogRetentionDays !== previousRetentionDays) {platformSideEffects(log).onAuditLogRetentionUpdated({platformId: params.id,@@ -231,6 +233,15 @@ export const platformService = (log: FastifyBaseLogger) => ({instanceLimitDays: auditLogRetentionCeiling.get(),})}+ const authenticationEvents = authenticationAuditEvents.build({ before: locked, after: saved })+ if (authenticationEvents.length > 0) {+ platformSideEffects(log).onAuthenticationSettingsChanged({+ platformId: params.id,+ userId: params.userId,+ ip: params.ip,+ events: authenticationEvents,+ })+ }return stripFederatedAuth(saved)},async getOneOrThrow(id: PlatformId): Promise<PlatformWithoutFederatedAuth> {@@ -301,13 +312,22 @@ export const platformService = (log: FastifyBaseLogger) => ({},})-async function lockAuditLogRetentionDays({ entityManager, platformId }: { entityManager: EntityManager, platformId: PlatformId }): Promise<number | null> {- const locked = await platformRepo(entityManager).findOneOrFail({+async function lockPlatformForUpdate({ entityManager, platformId, includeFederatedAuth }: LockPlatformForUpdateParams): Promise<Platform> {+ return platformRepo(entityManager).findOneOrFail({where: { id: platformId },- select: { id: true, auditLogRetentionDays: true },+ select: {+ id: true,+ auditLogRetentionDays: true,+ emailAuthEnabled: true,+ googleAuthEnabled: true,+ allowedAuthDomains: true,+ enforceAllowedAuthDomains: true,+ ssoDomain: true,+ ssoDomainVerification: true,+ federatedAuthProviders: includeFederatedAuth,+ },lock: { mode: 'pessimistic_write' },})- return locked.auditLogRetentionDays ?? null}function findProvisionedOwner(users: User[]): PlatformOwner | undefined {@@ -480,6 +500,12 @@ type AssertAuditLogRetentionDaysAllowedParams = {auditLogRetentionDays: number | null | undefined}+type LockPlatformForUpdateParams = {+ entityManager: EntityManager+ platformId: PlatformId+ includeFederatedAuth: boolean+}+type UpdateParams = UpdatePlatformRequestBody & {id: PlatformIdplan?: Partial<PlatformPlanLimits>diff --git a/packages/server/api/test/integration/cloud/audit-event/authentication-audit-events.test.ts b/packages/server/api/test/integration/cloud/audit-event/authentication-audit-events.test.tsnew file mode 100644index 00000000000..da6b15c04a2--- /dev/null+++ b/packages/server/api/test/integration/cloud/audit-event/authentication-audit-events.test.ts@@ -0,0 +1,230 @@+import { ApplicationEvent, ApplicationEventName, SsoDomainVerification, SsoDomainVerificationRecordType, SsoDomainVerificationStatus } from '@activepieces/shared'+import dayjs from 'dayjs'+import { FastifyInstance } from 'fastify'+import { auditLogRepo } from '../../../../src/app/ee/audit-logs/audit-event-service'+import { authnSsoSamlService } from '../../../../src/app/ee/authentication/saml-authn/authn-sso-saml-service'+import { createTestContext } from '../../../helpers/test-context'+import { setupTestEnvironment, teardownTestEnvironment } from '../../../helpers/test-setup'++let app: FastifyInstance | null = null++beforeAll(async () => {+ app = await setupTestEnvironment()+})++afterAll(async () => {+ await teardownTestEnvironment()+})++describe('Authentication audit events', () => {+ it('records who turned off email sign-in', async () => {+ const ctx = await createTestContext(app!, { platform: { emailAuthEnabled: true }, plan: { auditLogEnabled: true } })++ await ctx.inject({+ method: 'POST',+ url: `/api/v1/platforms/${ctx.platform.id}`,+ body: { emailAuthEnabled: false },+ headers: { 'x-real-ip': '203.0.113.7' },+ })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 1 })++ expect(events).toEqual([expect.objectContaining({+ action: ApplicationEventName.EMAIL_SIGN_IN_DISABLED,+ userId: ctx.user.id,+ userEmail: ctx.userIdentity.email,+ ip: '203.0.113.7',+ })])+ })++ it('records nothing for a save that leaves authentication as it was', async () => {+ const ctx = await createTestContext(app!, {+ platform: { emailAuthEnabled: true, allowedAuthDomains: ['a.com', 'b.com'] },+ plan: { auditLogEnabled: true },+ })++ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { name: 'Renamed', emailAuthEnabled: true, allowedAuthDomains: ['b.com', 'a.com'] })+ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { emailAuthEnabled: false })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 1 })++ expect(events.map((event) => event.action)).toEqual([ApplicationEventName.EMAIL_SIGN_IN_DISABLED])+ })++ it('records one row per allowed domain added and removed', async () => {+ const ctx = await createTestContext(app!, { platform: { allowedAuthDomains: ['a.com', 'b.com'] }, plan: { auditLogEnabled: true } })++ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { allowedAuthDomains: ['b.com', 'c.com'], enforceAllowedAuthDomains: true })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 3 })++ expect(events).toEqual(expect.arrayContaining([+ domainEvent({ action: ApplicationEventName.ALLOWED_DOMAIN_ADDED, domain: 'c.com' }),+ domainEvent({ action: ApplicationEventName.ALLOWED_DOMAIN_REMOVED, domain: 'a.com' }),+ expect.objectContaining({ action: ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED }),+ ]))+ })++ it('records allowed-domain enforcement being turned off', async () => {+ const ctx = await createTestContext(app!, { platform: { allowedAuthDomains: ['acme.com'], enforceAllowedAuthDomains: true }, plan: { auditLogEnabled: true } })++ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { enforceAllowedAuthDomains: false })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 1 })++ expect(events.map((event) => event.action)).toEqual([ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED])+ })++ it('records allowed-domain enforcement being turned on without a domain change', async () => {+ const ctx = await createTestContext(app!, { platform: { allowedAuthDomains: ['acme.com'], enforceAllowedAuthDomains: false }, plan: { auditLogEnabled: true } })++ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { enforceAllowedAuthDomains: true })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 1 })++ expect(events.map((event) => event.action)).toEqual([ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED])+ })++ it('records only the new domain when another is added while enforcement is already on', async () => {+ const ctx = await createTestContext(app!, {+ platform: { emailAuthEnabled: true, allowedAuthDomains: ['acme.com'], enforceAllowedAuthDomains: true },+ plan: { auditLogEnabled: true },+ })++ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { allowedAuthDomains: ['acme.com', 'acme.io'], enforceAllowedAuthDomains: true })+ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { emailAuthEnabled: false })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 2 })++ expect(sortedActions(events)).toEqual([ApplicationEventName.ALLOWED_DOMAIN_ADDED, ApplicationEventName.EMAIL_SIGN_IN_DISABLED].sort())+ expect(events).toEqual(expect.arrayContaining([domainEvent({ action: ApplicationEventName.ALLOWED_DOMAIN_ADDED, domain: 'acme.io' })]))+ })++ it('records the last domain removal and enforcement turning off', async () => {+ const ctx = await createTestContext(app!, { platform: { allowedAuthDomains: ['acme.com'], enforceAllowedAuthDomains: true }, plan: { auditLogEnabled: true } })++ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { allowedAuthDomains: [], enforceAllowedAuthDomains: false })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 2 })++ expect(sortedActions(events)).toEqual([ApplicationEventName.ALLOWED_DOMAIN_REMOVED, ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED].sort())+ expect(events).toEqual(expect.arrayContaining([domainEvent({ action: ApplicationEventName.ALLOWED_DOMAIN_REMOVED, domain: 'acme.com' })]))+ })++ it('treats a case-only change to an allowed domain as no change', async () => {+ const ctx = await createTestContext(app!, { platform: { emailAuthEnabled: true, allowedAuthDomains: ['acme.com'] }, plan: { auditLogEnabled: true } })++ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { allowedAuthDomains: ['ACME.com'] })+ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { emailAuthEnabled: false })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 1 })++ expect(events.map((event) => event.action)).toEqual([ApplicationEventName.EMAIL_SIGN_IN_DISABLED])+ })++ it('records a newly added domain as saved, ignoring a case-only change to another', async () => {+ const ctx = await createTestContext(app!, {+ platform: { emailAuthEnabled: true, allowedAuthDomains: ['acme.com'] },+ plan: { auditLogEnabled: true },+ })++ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { allowedAuthDomains: ['ACME.com', 'New.io'] })+ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { emailAuthEnabled: false })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 2 })++ expect(sortedActions(events)).toEqual([ApplicationEventName.ALLOWED_DOMAIN_ADDED, ApplicationEventName.EMAIL_SIGN_IN_DISABLED].sort())+ expect(events).toEqual(expect.arrayContaining([domainEvent({ action: ApplicationEventName.ALLOWED_DOMAIN_ADDED, domain: 'New.io' })]))+ })++ it('records the SSO domain being added and its verification being cancelled', async () => {+ const ctx = await createTestContext(app!, { plan: { auditLogEnabled: true, ssoEnabled: true } })++ await ctx.post(SSO_DOMAIN, { ssoDomain: 'pending.example.com' })+ await ctx.post(SSO_DOMAIN, { ssoDomain: null })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 2 })++ expect(events).toEqual(expect.arrayContaining([+ domainEvent({ action: ApplicationEventName.SSO_DOMAIN_ADDED, domain: 'pending.example.com', userId: ctx.user.id }),+ domainEvent({ action: ApplicationEventName.SSO_DOMAIN_VERIFICATION_CANCELLED, domain: 'pending.example.com', userId: ctx.user.id }),+ ]))+ })++ it('records the domain removal and single sign-on being disabled as two rows', async () => {+ const ctx = await createTestContext(app!, {+ plan: { auditLogEnabled: true, ssoEnabled: true },+ platform: {+ ssoDomain: 'verified.example.com',+ ssoDomainVerification: verification({ domain: 'verified.example.com', status: SsoDomainVerificationStatus.VERIFIED }),+ federatedAuthProviders: { saml: SAML },+ },+ })++ await ctx.post(SSO_DOMAIN, { ssoDomain: null })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 2 })++ expect(events.map((event) => event.action)).toEqual(expect.arrayContaining([+ ApplicationEventName.SSO_DOMAIN_REMOVED,+ ApplicationEventName.SSO_DISABLED,+ ]))+ })++ it('records a replaced SAML connection, and nothing when the same values are saved again', async () => {+ const ctx = await createTestContext(app!, {+ plan: { auditLogEnabled: true, ssoEnabled: true },+ platform: {+ ssoDomain: 'saml.example.com',+ ssoDomainVerification: verification({ domain: 'saml.example.com', status: SsoDomainVerificationStatus.VERIFIED }),+ federatedAuthProviders: { saml: SAML },+ },+ })++ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { federatedAuthProviders: { saml: SAML } })+ await ctx.post(`/v1/platforms/${ctx.platform.id}`, { federatedAuthProviders: { saml: { ...SAML, idpCertificate: 'rotated-certificate' } } })+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 1 })++ expect(events.map((event) => event.action)).toEqual([ApplicationEventName.SAML_CONNECTION_REPLACED])+ })++ it('records an expired domain with no user', async () => {+ const ctx = await createTestContext(app!, {+ plan: { auditLogEnabled: true, ssoEnabled: true },+ platform: {+ ssoDomain: 'expired.example.com',+ ssoDomainVerification: {+ ...verification({ domain: 'expired.example.com', status: SsoDomainVerificationStatus.PENDING_VERIFICATION }),+ createdAt: dayjs().subtract(8, 'days').toISOString(),+ },+ },+ })++ await authnSsoSamlService(app!.log).expirePendingSsoDomains()+ const events = await savedEvents({ platformId: ctx.platform.id, expectedCount: 1 })++ expect(events).toEqual([domainEvent({ action: ApplicationEventName.SSO_DOMAIN_EXPIRED, domain: 'expired.example.com', userId: null })])+ })+})++async function savedEvents({ platformId, expectedCount }: { platformId: string, expectedCount: number }): Promise<ApplicationEvent[]> {+ const find = async (): Promise<ApplicationEvent[]> => auditLogRepo().find({ where: { platformId }, order: { created: 'ASC' } })+ await vi.waitUntil(async () => (await find()).length >= expectedCount, { timeout: 5000, interval: 50 })+ return find()+}++function sortedActions(events: ApplicationEvent[]): ApplicationEventName[] {+ return events.map((event) => event.action).sort()+}++function domainEvent({ action, domain, userId }: { action: ApplicationEventName, domain: string, userId?: string | null }): unknown {+ return expect.objectContaining({+ action,+ data: expect.objectContaining({ domain }),+ ...(userId === undefined ? {} : { userId }),+ })+}++function verification({ domain, status }: { domain: string, status: SsoDomainVerificationStatus }): SsoDomainVerification {+ return {+ status,+ record: { type: SsoDomainVerificationRecordType.TXT, name: `_activepieces-verify.${domain}`, value: 'activepieces-verify=test-token' },+ createdAt: new Date().toISOString(),+ }+}++const SSO_DOMAIN = '/v1/authn/saml/sso-domain'++const SAML = {+ idpMetadata: '<EntityDescriptor />',+ idpCertificate: 'test-certificate',+}diff --git a/packages/server/api/test/integration/cloud/authn/cloud-authn.test.ts b/packages/server/api/test/integration/cloud/authn/cloud-authn.test.tsindex bc5e319edd7..a267a255b5e 100644--- a/packages/server/api/test/integration/cloud/authn/cloud-authn.test.ts+++ b/packages/server/api/test/integration/cloud/authn/cloud-authn.test.ts@@ -655,6 +655,50 @@ describe('Authentication API', () => {expect(responseBody?.code).toBe('DOMAIN_NOT_ALLOWED')})++ it('Signs in when the allowed domain differs only in case', async () => {+ const mockPlatformId = faker.string.nanoid()+ const mockPlatformDomain = faker.internet.domainName().toLowerCase()++ await mockAndSaveBasicSetup({+ platform: {+ id: mockPlatformId,+ allowedAuthDomains: [mockPlatformDomain.toUpperCase()],+ enforceAllowedAuthDomains: true,+ emailAuthEnabled: true,+ },+ plan: {+ ssoEnabled: true,+ },+ })+ const rawPassword = faker.internet.password()+ const { mockUserIdentity } = await mockBasicUser({+ user: {+ status: UserStatus.ACTIVE,+ platformId: mockPlatformId,+ platformRole: PlatformRole.ADMIN,+ },+ userIdentity: {+ email: `${faker.internet.username().toLowerCase()}@${mockPlatformDomain}`,+ password: rawPassword,+ verified: true,+ },+ })++ const response = await app?.inject({+ method: 'POST',+ url: '/api/v1/authentication/sign-in',+ headers: {+ Host: mockPlatformDomain,+ },+ body: createMockSignInRequest({+ email: mockUserIdentity.email,+ password: rawPassword,+ }),+ })++ expect(response?.statusCode).toBe(StatusCodes.OK)+ })})diff --git a/packages/web/public/locales/en/translation.json b/packages/web/public/locales/en/translation.jsonindex 0b0ee53b081..e9c58da58ad 100644--- a/packages/web/public/locales/en/translation.json+++ b/packages/web/public/locales/en/translation.json@@ -1519,6 +1519,22 @@"User email verified": "User email verified","Signing key created": "Signing key created","Audit log retention updated": "Audit log retention updated",+ "Email sign-in turned on": "Email sign-in turned on",+ "Email sign-in turned off": "Email sign-in turned off",+ "Google sign-in turned on": "Google sign-in turned on",+ "Google sign-in turned off": "Google sign-in turned off",+ "Allowed domain removed": "Allowed domain removed",+ "Allowed domain enforcement turned on": "Allowed domain enforcement turned on",+ "Allowed domain enforcement turned off": "Allowed domain enforcement turned off",+ "SSO domain added": "SSO domain added",+ "SSO domain verified": "SSO domain verified",+ "SSO domain verification cancelled": "SSO domain verification cancelled",+ "SSO domain removed": "SSO domain removed",+ "SSO domain expired": "SSO domain expired",+ "SAML connected": "SAML connected",+ "SAML connection replaced": "SAML connection replaced",+ "Single sign-on disabled": "Single sign-on disabled",+ "Authentication & SSO": "Authentication & SSO","Project role created": "Project role created","Project role updated": "Project role updated","Project role deleted": "Project role deleted",diff --git a/packages/web/src/app/routes/platform/infra/event-destinations/lib/event-groups.ts b/packages/web/src/app/routes/platform/infra/event-destinations/lib/event-groups.tsindex b19acbb5a87..ae352adcdad 100644--- a/packages/web/src/app/routes/platform/infra/event-destinations/lib/event-groups.ts+++ b/packages/web/src/app/routes/platform/infra/event-destinations/lib/event-groups.ts@@ -87,6 +87,28 @@ function buildEventGroups(): EventGroup[] {ApplicationEventName.AUDIT_LOG_RETENTION_UPDATED,],},+ {+ key: 'authentication',+ title: t('Authentication & SSO'),+ events: [+ ApplicationEventName.EMAIL_SIGN_IN_ENABLED,+ ApplicationEventName.EMAIL_SIGN_IN_DISABLED,+ ApplicationEventName.GOOGLE_SIGN_IN_ENABLED,+ ApplicationEventName.GOOGLE_SIGN_IN_DISABLED,+ ApplicationEventName.ALLOWED_DOMAIN_ADDED,+ ApplicationEventName.ALLOWED_DOMAIN_REMOVED,+ ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED,+ ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED,+ ApplicationEventName.SSO_DOMAIN_ADDED,+ ApplicationEventName.SSO_DOMAIN_VERIFIED,+ ApplicationEventName.SSO_DOMAIN_VERIFICATION_CANCELLED,+ ApplicationEventName.SSO_DOMAIN_REMOVED,+ ApplicationEventName.SSO_DOMAIN_EXPIRED,+ ApplicationEventName.SAML_CONNECTED,+ ApplicationEventName.SAML_CONNECTION_REPLACED,+ ApplicationEventName.SSO_DISABLED,+ ],+ },{key: 'projects',title: t('Projects'),diff --git a/packages/web/src/app/routes/platform/infra/event-destinations/lib/event-labels.ts b/packages/web/src/app/routes/platform/infra/event-destinations/lib/event-labels.tsindex f42f6b3a9d6..14d5285f772 100644--- a/packages/web/src/app/routes/platform/infra/event-destinations/lib/event-labels.ts+++ b/packages/web/src/app/routes/platform/infra/event-destinations/lib/event-labels.ts@@ -36,6 +36,36 @@ export const buildEventLabels = (): EventLabelsMap => {[ApplicationEventName.AUDIT_LOG_RETENTION_UPDATED]: t('Audit log retention updated',),+ [ApplicationEventName.EMAIL_SIGN_IN_ENABLED]: t('Email sign-in turned on'),+ [ApplicationEventName.EMAIL_SIGN_IN_DISABLED]: t(+ 'Email sign-in turned off',+ ),+ [ApplicationEventName.GOOGLE_SIGN_IN_ENABLED]: t(+ 'Google sign-in turned on',+ ),+ [ApplicationEventName.GOOGLE_SIGN_IN_DISABLED]: t(+ 'Google sign-in turned off',+ ),+ [ApplicationEventName.ALLOWED_DOMAIN_ADDED]: t('Allowed domain added'),+ [ApplicationEventName.ALLOWED_DOMAIN_REMOVED]: t('Allowed domain removed'),+ [ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED]: t(+ 'Allowed domain enforcement turned on',+ ),+ [ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED]: t(+ 'Allowed domain enforcement turned off',+ ),+ [ApplicationEventName.SSO_DOMAIN_ADDED]: t('SSO domain added'),+ [ApplicationEventName.SSO_DOMAIN_VERIFIED]: t('SSO domain verified'),+ [ApplicationEventName.SSO_DOMAIN_VERIFICATION_CANCELLED]: t(+ 'SSO domain verification cancelled',+ ),+ [ApplicationEventName.SSO_DOMAIN_REMOVED]: t('SSO domain removed'),+ [ApplicationEventName.SSO_DOMAIN_EXPIRED]: t('SSO domain expired'),+ [ApplicationEventName.SAML_CONNECTED]: t('SAML connected'),+ [ApplicationEventName.SAML_CONNECTION_REPLACED]: t(+ 'SAML connection replaced',+ ),+ [ApplicationEventName.SSO_DISABLED]: t('Single sign-on disabled'),[ApplicationEventName.PROJECT_ROLE_CREATED]: t('Project role created'),[ApplicationEventName.PROJECT_ROLE_UPDATED]: t('Project role updated'),[ApplicationEventName.PROJECT_ROLE_DELETED]: t('Project role deleted'),diff --git a/packages/web/src/app/routes/platform/security/audit-logs/index.tsx b/packages/web/src/app/routes/platform/security/audit-logs/index.tsxindex 1ae595e6a4b..94c2b1e10d2 100644--- a/packages/web/src/app/routes/platform/security/audit-logs/index.tsx+++ b/packages/web/src/app/routes/platform/security/audit-logs/index.tsx@@ -25,6 +25,7 @@ import {FileText,User,Clock,+ ShieldCheck,} from 'lucide-react';import { Fragment, useState } from 'react';import { Link } from 'react-router-dom';@@ -36,6 +37,7 @@ import {adminPageResources,adminLayout,} from '@/app/components/admin';+import { buildEventLabels } from '@/app/routes/platform/infra/event-destinations/lib/event-labels';import { DataTableFilters } from '@/components/custom/data-table';import { DataTableColumnHeader } from '@/components/custom/data-table/data-table-column-header';import { FormattedDate } from '@/components/custom/formatted-date';@@ -70,6 +72,7 @@ export default function AuditLogsPage() {const [isSheetOpen, setIsSheetOpen] = useState(false);const { data: projects } = projectCollectionUtils.useAll();const { data: users } = platformUserHooks.useUsers();+ const eventLabels = buildEventLabels();const filters: DataTableFilters<keyof ApplicationEvent>[] = [{@@ -78,7 +81,7 @@ export default function AuditLogsPage() {accessorKey: 'action',options: Object.values(ApplicationEventName).map((action) => {return {- label: formatUtils.convertEnumToHumanReadable(action),+ label: eventLabels[action],value: action,};}),@@ -161,7 +164,7 @@ export default function AuditLogsPage() {{!isNil(icon?.icon) && (<span className="text-gray-11 shrink-0">{icon.icon}</span>)}- {formatUtils.convertEnumToHumanReadable(row.original.action)}+ {eventLabels[row.original.action]}</div>);},@@ -267,9 +270,7 @@ export default function AuditLogsPage() {<SheetContent className={cn(adminLayout.sheet.md, 'flex flex-col p-0')}><SheetHeader className="px-6 py-4 border-b shrink-0"><SheetTitle className="text-base">- {formatUtils.convertEnumToHumanReadable(- selectedEvent?.action ?? '',- )}+ {selectedEvent && eventLabels[selectedEvent.action]}</SheetTitle><p className="text-sm text-gray-11 mt-1">{selectedEvent && convertToDetails(selectedEvent)}@@ -418,6 +419,26 @@ function convertToIcon(event: ApplicationEvent) {icon: <Clock className="size-4" />,tooltip: t('Audit log retention'),};+ case ApplicationEventName.EMAIL_SIGN_IN_ENABLED:+ case ApplicationEventName.EMAIL_SIGN_IN_DISABLED:+ case ApplicationEventName.GOOGLE_SIGN_IN_ENABLED:+ case ApplicationEventName.GOOGLE_SIGN_IN_DISABLED:+ case ApplicationEventName.ALLOWED_DOMAIN_ADDED:+ case ApplicationEventName.ALLOWED_DOMAIN_REMOVED:+ case ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED:+ case ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED:+ case ApplicationEventName.SSO_DOMAIN_ADDED:+ case ApplicationEventName.SSO_DOMAIN_VERIFIED:+ case ApplicationEventName.SSO_DOMAIN_VERIFICATION_CANCELLED:+ case ApplicationEventName.SSO_DOMAIN_REMOVED:+ case ApplicationEventName.SSO_DOMAIN_EXPIRED:+ case ApplicationEventName.SAML_CONNECTED:+ case ApplicationEventName.SAML_CONNECTION_REPLACED:+ case ApplicationEventName.SSO_DISABLED:+ return {+ icon: <ShieldCheck className="size-4" />,+ tooltip: t('Authentication'),+ };default:return undefined;}@@ -623,6 +644,24 @@ function extractEventDetails(event: ApplicationEvent): EventDetailRow[] {},];}+ case ApplicationEventName.ALLOWED_DOMAIN_ADDED:+ case ApplicationEventName.ALLOWED_DOMAIN_REMOVED:+ case ApplicationEventName.SSO_DOMAIN_ADDED:+ case ApplicationEventName.SSO_DOMAIN_VERIFIED:+ case ApplicationEventName.SSO_DOMAIN_VERIFICATION_CANCELLED:+ case ApplicationEventName.SSO_DOMAIN_REMOVED:+ case ApplicationEventName.SSO_DOMAIN_EXPIRED:+ return [{ label: t('Domain'), value: event.data.domain }];+ case ApplicationEventName.EMAIL_SIGN_IN_ENABLED:+ case ApplicationEventName.EMAIL_SIGN_IN_DISABLED:+ case ApplicationEventName.GOOGLE_SIGN_IN_ENABLED:+ case ApplicationEventName.GOOGLE_SIGN_IN_DISABLED:+ case ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_ENABLED:+ case ApplicationEventName.ALLOWED_DOMAIN_ENFORCEMENT_DISABLED:+ case ApplicationEventName.SAML_CONNECTED:+ case ApplicationEventName.SAML_CONNECTION_REPLACED:+ case ApplicationEventName.SSO_DISABLED:+ return [];case ApplicationEventName.PROJECT_ROLE_CREATED:case ApplicationEventName.PROJECT_ROLE_UPDATED:case ApplicationEventName.PROJECT_ROLE_DELETED: {