mirror of
https://github.com/bitwarden/browser
synced 2026-01-07 11:03:30 +00:00
[SM-1274] Add Project Events to the Log List in Admin Console (#15442)
* Adding enums for additional event logs for secrets * updating messages * Updating messages to be consistent for logs * Displaying project logs, and fixing search query param searching in projects list, having deleted log for secrets and projects not show as a link * Viewing secret and project event logs in event modal, adding to the context menu for secrets and projects the ability to view the logs if user has permission. Restricting logs to SM projs and Secs if the logged in user has event log access but not SM access. * lint * Lint Fixes * fix to messages file * fixing lint * Bug fix, make sure event logs related to service accounts are still links that take you to the object * removing unused import
This commit is contained in:
@@ -467,21 +467,60 @@ export class EventService {
|
||||
break;
|
||||
// Secrets Manager
|
||||
case EventType.Secret_Retrieved:
|
||||
msg = this.i18nService.t("accessedSecretWithId", this.formatSecretId(ev));
|
||||
msg = this.i18nService.t("accessedSecretWithId", this.formatSecretId(ev, options));
|
||||
humanReadableMsg = this.i18nService.t("accessedSecretWithId", this.getShortId(ev.secretId));
|
||||
break;
|
||||
case EventType.Secret_Created:
|
||||
msg = this.i18nService.t("createdSecretWithId", this.formatSecretId(ev));
|
||||
msg = this.i18nService.t("createdSecretWithId", this.formatSecretId(ev, options));
|
||||
humanReadableMsg = this.i18nService.t("createdSecretWithId", this.getShortId(ev.secretId));
|
||||
break;
|
||||
case EventType.Secret_Deleted:
|
||||
msg = this.i18nService.t("deletedSecretWithId", this.formatSecretId(ev));
|
||||
msg = this.i18nService.t("deletedSecretWithId", this.formatSecretId(ev, options));
|
||||
humanReadableMsg = this.i18nService.t("deletedSecretWithId", this.getShortId(ev.secretId));
|
||||
break;
|
||||
case EventType.Secret_Permanently_Deleted:
|
||||
msg = this.i18nService.t(
|
||||
"permanentlyDeletedSecretWithId",
|
||||
this.formatSecretId(ev, options),
|
||||
);
|
||||
humanReadableMsg = this.i18nService.t(
|
||||
"permanentlyDeletedSecretWithId",
|
||||
this.getShortId(ev.secretId),
|
||||
);
|
||||
break;
|
||||
case EventType.Secret_Restored:
|
||||
msg = this.i18nService.t("restoredSecretWithId", this.formatSecretId(ev, options));
|
||||
humanReadableMsg = this.i18nService.t("restoredSecretWithId", this.getShortId(ev.secretId));
|
||||
break;
|
||||
case EventType.Secret_Edited:
|
||||
msg = this.i18nService.t("editedSecretWithId", this.formatSecretId(ev));
|
||||
msg = this.i18nService.t("editedSecretWithId", this.formatSecretId(ev, options));
|
||||
humanReadableMsg = this.i18nService.t("editedSecretWithId", this.getShortId(ev.secretId));
|
||||
break;
|
||||
case EventType.Project_Retrieved:
|
||||
msg = this.i18nService.t("accessedProjectWithId", this.formatProjectId(ev, options));
|
||||
humanReadableMsg = this.i18nService.t(
|
||||
"accessedProjectWithId",
|
||||
this.getShortId(ev.projectId),
|
||||
);
|
||||
break;
|
||||
case EventType.Project_Created:
|
||||
msg = this.i18nService.t("createdProjectWithId", this.formatProjectId(ev, options));
|
||||
humanReadableMsg = this.i18nService.t(
|
||||
"createdProjectWithId",
|
||||
this.getShortId(ev.projectId),
|
||||
);
|
||||
break;
|
||||
case EventType.Project_Deleted:
|
||||
msg = this.i18nService.t("deletedProjectWithId", this.formatProjectId(ev, options));
|
||||
humanReadableMsg = this.i18nService.t(
|
||||
"deletedProjectWithId",
|
||||
this.getShortId(ev.projectId),
|
||||
);
|
||||
break;
|
||||
case EventType.Project_Edited:
|
||||
msg = this.i18nService.t("editedProjectWithId", this.formatProjectId(ev, options));
|
||||
humanReadableMsg = this.i18nService.t("editedProjectWithId", this.getShortId(ev.projectId));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -637,10 +676,41 @@ export class EventService {
|
||||
return a.outerHTML;
|
||||
}
|
||||
|
||||
formatSecretId(ev: EventResponse): string {
|
||||
formatSecretId(ev: EventResponse, options: EventOptions): string {
|
||||
const shortId = this.getShortId(ev.secretId);
|
||||
if (options.disableLink) {
|
||||
return shortId;
|
||||
}
|
||||
const a = this.makeAnchor(shortId);
|
||||
a.setAttribute("href", "#/sm/" + ev.organizationId + "/secrets?search=" + shortId);
|
||||
a.setAttribute(
|
||||
"href",
|
||||
"#/sm/" +
|
||||
ev.organizationId +
|
||||
"/secrets?search=" +
|
||||
shortId +
|
||||
"&viewEvents=" +
|
||||
ev.secretId +
|
||||
"&type=all",
|
||||
);
|
||||
return a.outerHTML;
|
||||
}
|
||||
|
||||
formatProjectId(ev: EventResponse, options: EventOptions): string {
|
||||
const shortId = this.getShortId(ev.projectId);
|
||||
if (options.disableLink) {
|
||||
return shortId;
|
||||
}
|
||||
const a = this.makeAnchor(shortId);
|
||||
a.setAttribute(
|
||||
"href",
|
||||
"#/sm/" +
|
||||
ev.organizationId +
|
||||
"/projects?search=" +
|
||||
shortId +
|
||||
"&viewEvents=" +
|
||||
ev.projectId +
|
||||
"&type=all",
|
||||
);
|
||||
return a.outerHTML;
|
||||
}
|
||||
|
||||
@@ -684,4 +754,5 @@ export class EventInfo {
|
||||
|
||||
export class EventOptions {
|
||||
cipherInfo = true;
|
||||
disableLink = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user