Skip to content

Commit 84c4670

Browse files
committed
Preserve sso context in authentication event deserialisation
The Events API includes an sso object (with connection_id, organization_id, and optionally session_id) in authentication.sso_* event data, but the deserialiser was silently dropping it. Adds AuthenticationEventSso and AuthenticationEventSsoResponse interfaces, and a deserializeAuthenticationEventSso helper that follows the existing deserializeOauthTokens pattern for nested optional objects with snake_case conversion.
1 parent 084e463 commit 84c4670

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/user-management/interfaces/authentication-event.interface.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ interface AuthenticationEventError {
33
message: string;
44
}
55

6+
export interface AuthenticationEventSso {
7+
connectionId: string;
8+
organizationId: string;
9+
sessionId?: string;
10+
}
11+
12+
export interface AuthenticationEventSsoResponse {
13+
connection_id: string;
14+
organization_id: string;
15+
session_id?: string;
16+
}
17+
618
type AuthenticationEventType =
719
| 'sso'
820
| 'password'
@@ -17,6 +29,7 @@ export type AuthenticationEvent = {
1729
email: string | null;
1830
error?: AuthenticationEventError;
1931
ipAddress: string | null;
32+
sso?: AuthenticationEventSso;
2033
status: AuthenticationEventStatus;
2134
type: AuthenticationEventType;
2235
userAgent: string | null;
@@ -27,6 +40,7 @@ export interface AuthenticationEventResponse {
2740
email: string | null;
2841
error?: AuthenticationEventError;
2942
ip_address: string | null;
43+
sso?: AuthenticationEventSsoResponse;
3044
status: AuthenticationEventStatus;
3145
type: AuthenticationEventType;
3246
user_agent: string | null;

src/user-management/serializers/authentication-event.serializer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
import {
22
AuthenticationEvent,
33
AuthenticationEventResponse,
4+
AuthenticationEventSso,
5+
AuthenticationEventSsoResponse,
46
} from '../interfaces';
57

8+
const deserializeAuthenticationEventSso = (
9+
sso: AuthenticationEventSsoResponse,
10+
): AuthenticationEventSso => ({
11+
connectionId: sso.connection_id,
12+
organizationId: sso.organization_id,
13+
...(sso.session_id && { sessionId: sso.session_id }),
14+
});
15+
616
export const deserializeAuthenticationEvent = (
717
authenticationEvent: AuthenticationEventResponse,
818
): AuthenticationEvent => ({
919
email: authenticationEvent.email,
1020
error: authenticationEvent.error,
1121
ipAddress: authenticationEvent.ip_address,
22+
...(authenticationEvent.sso && {
23+
sso: deserializeAuthenticationEventSso(authenticationEvent.sso),
24+
}),
1225
status: authenticationEvent.status,
1326
type: authenticationEvent.type,
1427
userAgent: authenticationEvent.user_agent,

0 commit comments

Comments
 (0)