Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 248 additions & 3 deletions apps/web/src/app/core/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic

@Injectable()
export class EventService {
private policies: Policy[];
private policies: Policy[] = [];

constructor(
private i18nService: I18nService,
Expand Down Expand Up @@ -200,6 +200,10 @@ export class EventService {
this.getShortId(ev.cipherId),
);
break;
case EventType.Cipher_ClientToggledTOTPSeedVisible:
msg = this.i18nService.t("viewedTOTPSeedItemId", this.formatCipherId(ev, options));
humanReadableMsg = this.i18nService.t("viewedTOTPSeedItemId", this.getShortId(ev.cipherId));
break;
// Collection
case EventType.Collection_Created:
msg = this.i18nService.t("createdCollectionId", this.formatCollectionId(ev));
Expand Down Expand Up @@ -669,6 +673,246 @@ export class EventService {
this.formatServiceAccountId(ev, options),
);
break;
case EventType.ServiceAccount_UserPermissionUpdated:
msg = this.i18nService.t(
"updatedUserPermissionForServiceAccountWithId",
this.formatUserId(ev, options),
this.formatServiceAccountId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"updatedUserPermissionForServiceAccountWithId",
this.getShortId(ev.userId),
this.getShortId(ev.serviceAccountId ?? ev.grantedServiceAccountId),
);
break;
case EventType.ServiceAccount_GroupPermissionUpdated:
msg = this.i18nService.t(
"updatedGroupPermissionForServiceAccountWithId",
this.formatGroupId(ev),
this.formatServiceAccountId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"updatedGroupPermissionForServiceAccountWithId",
this.getShortId(ev.groupId),
this.getShortId(ev.serviceAccountId ?? ev.grantedServiceAccountId),
);
break;
case EventType.Secret_UserAccessGranted:
msg = this.i18nService.t(
"grantedUserAccessToSecretWithId",
this.formatOrgUserId(ev),
this.formatSecretId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"grantedUserAccessToSecretWithId",
this.getShortId(ev.organizationUserId),
this.getShortId(ev.secretId),
);
break;
case EventType.Secret_UserAccessRevoked:
msg = this.i18nService.t(
"revokedUserAccessToSecretWithId",
this.formatOrgUserId(ev),
this.formatSecretId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"revokedUserAccessToSecretWithId",
this.getShortId(ev.organizationUserId),
this.getShortId(ev.secretId),
);
break;
case EventType.Secret_UserAccessUpdated:
msg = this.i18nService.t(
"updatedUserAccessToSecretWithId",
this.formatOrgUserId(ev),
this.formatSecretId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"updatedUserAccessToSecretWithId",
this.getShortId(ev.organizationUserId),
this.getShortId(ev.secretId),
);
break;
case EventType.Secret_GroupAccessGranted:
msg = this.i18nService.t(
"grantedGroupAccessToSecretWithId",
this.formatGroupId(ev),
this.formatSecretId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"grantedGroupAccessToSecretWithId",
this.getShortId(ev.groupId),
this.getShortId(ev.secretId),
);
break;
case EventType.Secret_GroupAccessRevoked:
msg = this.i18nService.t(
"revokedGroupAccessToSecretWithId",
this.formatGroupId(ev),
this.formatSecretId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"revokedGroupAccessToSecretWithId",
this.getShortId(ev.groupId),
this.getShortId(ev.secretId),
);
break;
case EventType.Secret_GroupAccessUpdated:
msg = this.i18nService.t(
"updatedGroupAccessToSecretWithId",
this.formatGroupId(ev),
this.formatSecretId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"updatedGroupAccessToSecretWithId",
this.getShortId(ev.groupId),
this.getShortId(ev.secretId),
);
break;
case EventType.Secret_ServiceAccountAccessGranted:
msg = this.i18nService.t(
"grantedMachineAccountAccessToSecretWithId",
this.formatServiceAccountId(ev, options),
this.formatSecretId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"grantedMachineAccountAccessToSecretWithId",
this.getShortId(ev.grantedServiceAccountId),
this.getShortId(ev.secretId),
);
break;
case EventType.Secret_ServiceAccountAccessRevoked:
msg = this.i18nService.t(
"revokedMachineAccountAccessToSecretWithId",
this.formatServiceAccountId(ev, options),
this.formatSecretId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"revokedMachineAccountAccessToSecretWithId",
this.getShortId(ev.grantedServiceAccountId),
this.getShortId(ev.secretId),
);
break;
case EventType.Secret_ServiceAccountAccessUpdated:
msg = this.i18nService.t(
"updatedMachineAccountAccessToSecretWithId",
this.formatServiceAccountId(ev, options),
this.formatSecretId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"updatedMachineAccountAccessToSecretWithId",
this.getShortId(ev.grantedServiceAccountId),
this.getShortId(ev.secretId),
);
break;
case EventType.Project_UserAccessGranted:
msg = this.i18nService.t(
"grantedUserAccessToProjectWithId",
this.formatOrgUserId(ev),
this.formatProjectId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"grantedUserAccessToProjectWithId",
this.getShortId(ev.organizationUserId),
this.getShortId(ev.projectId),
);
break;
case EventType.Project_UserAccessRevoked:
msg = this.i18nService.t(
"revokedUserAccessToProjectWithId",
this.formatOrgUserId(ev),
this.formatProjectId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"revokedUserAccessToProjectWithId",
this.getShortId(ev.organizationUserId),
this.getShortId(ev.projectId),
);
break;
case EventType.Project_UserAccessUpdated:
msg = this.i18nService.t(
"updatedUserAccessToProjectWithId",
this.formatOrgUserId(ev),
this.formatProjectId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"updatedUserAccessToProjectWithId",
this.getShortId(ev.organizationUserId),
this.getShortId(ev.projectId),
);
break;
case EventType.Project_GroupAccessGranted:
msg = this.i18nService.t(
"grantedGroupAccessToProjectWithId",
this.formatGroupId(ev),
this.formatProjectId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"grantedGroupAccessToProjectWithId",
this.getShortId(ev.groupId),
this.getShortId(ev.projectId),
);
break;
case EventType.Project_GroupAccessRevoked:
msg = this.i18nService.t(
"revokedGroupAccessToProjectWithId",
this.formatGroupId(ev),
this.formatProjectId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"revokedGroupAccessToProjectWithId",
this.getShortId(ev.groupId),
this.getShortId(ev.projectId),
);
break;
case EventType.Project_GroupAccessUpdated:
msg = this.i18nService.t(
"updatedGroupAccessToProjectWithId",
this.formatGroupId(ev),
this.formatProjectId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"updatedGroupAccessToProjectWithId",
this.getShortId(ev.groupId),
this.getShortId(ev.projectId),
);
break;
case EventType.Project_ServiceAccountAccessGranted:
msg = this.i18nService.t(
"grantedMachineAccountAccessToProjectWithId",
this.formatServiceAccountId(ev, options),
this.formatProjectId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"grantedMachineAccountAccessToProjectWithId",
this.getShortId(ev.grantedServiceAccountId),
this.getShortId(ev.projectId),
);
break;
case EventType.Project_ServiceAccountAccessRevoked:
msg = this.i18nService.t(
"revokedMachineAccountAccessToProjectWithId",
this.formatServiceAccountId(ev, options),
this.formatProjectId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"revokedMachineAccountAccessToProjectWithId",
this.getShortId(ev.grantedServiceAccountId),
this.getShortId(ev.projectId),
);
break;
case EventType.Project_ServiceAccountAccessUpdated:
msg = this.i18nService.t(
"updatedMachineAccountAccessToProjectWithId",
this.formatServiceAccountId(ev, options),
this.formatProjectId(ev, options),
);
humanReadableMsg = this.i18nService.t(
"updatedMachineAccountAccessToProjectWithId",
this.getShortId(ev.grantedServiceAccountId),
this.getShortId(ev.projectId),
);
break;
default:
break;
}
Expand Down Expand Up @@ -846,7 +1090,8 @@ export class EventService {
}

formatServiceAccountId(ev: EventResponse, options: EventOptions): string {
const shortId = this.getShortId(ev.grantedServiceAccountId);
const id = ev.serviceAccountId ?? ev.grantedServiceAccountId;
const shortId = this.getShortId(id);
if (options.disableLink) {
return shortId;
}
Expand All @@ -858,7 +1103,7 @@ export class EventService {
"/machine-accounts?search=" +
shortId +
"&viewEvents=" +
ev.grantedServiceAccountId +
id +
"&type=all",
);
return a.outerHTML;
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/app/tools/event-export/event.export.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventType } from "@bitwarden/common/enums";
import { eventTypeNames } from "@bitwarden/common/enums";
import { EventView } from "@bitwarden/common/models/view/event.view";

export class EventExport {
Expand All @@ -22,7 +22,7 @@ export class EventExport {
this.userEmail = event.userEmail;
this.date = event.date;
this.ip = event.ip;
this.type = EventType[event.type];
this.type = eventTypeNames[event.type];
this.installationId = event.installationId;
}
}
Loading
Loading