diff --git a/src/user-management/interfaces/authentication-event.interface.ts b/src/user-management/interfaces/authentication-event.interface.ts index 0254958b6..c395d6b9e 100644 --- a/src/user-management/interfaces/authentication-event.interface.ts +++ b/src/user-management/interfaces/authentication-event.interface.ts @@ -3,6 +3,18 @@ interface AuthenticationEventError { message: string; } +export interface AuthenticationEventSso { + connectionId: string; + organizationId: string; + sessionId?: string; +} + +export interface AuthenticationEventSsoResponse { + connection_id: string; + organization_id: string; + session_id?: string; +} + type AuthenticationEventType = | 'sso' | 'password' @@ -17,6 +29,7 @@ export type AuthenticationEvent = { email: string | null; error?: AuthenticationEventError; ipAddress: string | null; + sso?: AuthenticationEventSso; status: AuthenticationEventStatus; type: AuthenticationEventType; userAgent: string | null; @@ -27,6 +40,7 @@ export interface AuthenticationEventResponse { email: string | null; error?: AuthenticationEventError; ip_address: string | null; + sso?: AuthenticationEventSsoResponse; status: AuthenticationEventStatus; type: AuthenticationEventType; user_agent: string | null; diff --git a/src/user-management/serializers/authentication-event.serializer.ts b/src/user-management/serializers/authentication-event.serializer.ts index 969dfd63d..b77d87b28 100644 --- a/src/user-management/serializers/authentication-event.serializer.ts +++ b/src/user-management/serializers/authentication-event.serializer.ts @@ -1,8 +1,18 @@ import { AuthenticationEvent, AuthenticationEventResponse, + AuthenticationEventSso, + AuthenticationEventSsoResponse, } from '../interfaces'; +const deserializeAuthenticationEventSso = ( + sso: AuthenticationEventSsoResponse, +): AuthenticationEventSso => ({ + connectionId: sso.connection_id, + organizationId: sso.organization_id, + ...(sso.session_id !== undefined && { sessionId: sso.session_id }), +}); + export const deserializeAuthenticationEvent = ( authenticationEvent: AuthenticationEventResponse, ): AuthenticationEvent => ({ @@ -11,6 +21,9 @@ export const deserializeAuthenticationEvent = ( error: authenticationEvent.error, }), ipAddress: authenticationEvent.ip_address, + ...(authenticationEvent.sso !== undefined && { + sso: deserializeAuthenticationEventSso(authenticationEvent.sso), + }), status: authenticationEvent.status, type: authenticationEvent.type, userAgent: authenticationEvent.user_agent,