mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-19 17:32:37 +00:00
Merge pull request #4865 from Infisical/feat/addLoginAuditLogs
Add user login and select organization audit logs
This commit is contained in:
@@ -454,6 +454,30 @@ export const authLoginServiceFactory = ({
|
||||
});
|
||||
}
|
||||
|
||||
if (organizationId) {
|
||||
await auditLogService.createAuditLog({
|
||||
orgId: organizationId,
|
||||
ipAddress: ip,
|
||||
userAgent,
|
||||
userAgentType: getUserAgentType(userAgent),
|
||||
actor: {
|
||||
type: ActorType.USER,
|
||||
metadata: {
|
||||
email: userEnc.email,
|
||||
userId: userEnc.userId,
|
||||
username: userEnc.username,
|
||||
authMethod
|
||||
}
|
||||
},
|
||||
event: {
|
||||
type: EventType.USER_LOGIN,
|
||||
metadata: {
|
||||
organizationId
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
tokens: {
|
||||
accessToken: token.access,
|
||||
@@ -646,6 +670,29 @@ export const authLoginServiceFactory = ({
|
||||
}
|
||||
}
|
||||
|
||||
await auditLogService.createAuditLog({
|
||||
orgId: organizationId,
|
||||
ipAddress,
|
||||
userAgent,
|
||||
userAgentType: getUserAgentType(userAgent),
|
||||
actor: {
|
||||
type: ActorType.USER,
|
||||
metadata: {
|
||||
email: user.email,
|
||||
userId: user.id,
|
||||
username: user.username,
|
||||
authMethod: decodedToken.authMethod
|
||||
}
|
||||
},
|
||||
event: {
|
||||
type: EventType.SELECT_ORGANIZATION,
|
||||
metadata: {
|
||||
organizationId,
|
||||
organizationName: selectedOrg.name
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
...tokens,
|
||||
user,
|
||||
@@ -1039,6 +1086,33 @@ export const authLoginServiceFactory = ({
|
||||
organizationId
|
||||
});
|
||||
|
||||
if (organizationId) {
|
||||
await auditLogService.createAuditLog({
|
||||
orgId: organizationId,
|
||||
ipAddress: ip,
|
||||
userAgent,
|
||||
userAgentType: getUserAgentType(userAgent),
|
||||
actor: {
|
||||
type: ActorType.USER,
|
||||
metadata: {
|
||||
email: userEnc.email,
|
||||
userId: userEnc.userId,
|
||||
username: userEnc.username,
|
||||
authMethod: decodedProviderToken.authMethod
|
||||
}
|
||||
},
|
||||
event: {
|
||||
type: EventType.USER_LOGIN,
|
||||
metadata: {
|
||||
organizationId,
|
||||
...(isAuthMethodSaml(decodedProviderToken.authMethod) && {
|
||||
authProvider: decodedProviderToken.authMethod
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return { token, isMfaEnabled: false, user: userEnc, decodedProviderToken } as const;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user