Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ID-1230 Ensure Audit Log Events Have Same Schema #1431

Merged
merged 1 commit into from
May 7, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ case object ResourceParentUpdated extends ResourceEventType
case object ResourceParentRemoved extends ResourceEventType
case object ResourceDeleted extends ResourceEventType

final case class ResourceEvent(eventType: ResourceEventType, resource: FullyQualifiedResourceId, changeDetails: Option[ResourceChange] = None)
extends AuditEvent
final case class ResourceEvent(eventType: ResourceEventType, resource: FullyQualifiedResourceId, changeDetails: Set[ResourceChange] = Set()) extends AuditEvent

case class AccessChange(
member: WorkbenchSubject,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class ResourceService(

_ <- AuditLogger.logAuditEventIO(
samRequestContext,
ResourceEvent(ResourceCreated, FullyQualifiedResourceId(resourceType.name, resourceId), parentOpt.map(ResourceChange))
ResourceEvent(ResourceCreated, FullyQualifiedResourceId(resourceType.name, resourceId), parentOpt.map(ResourceChange).toSet)
)

changeEvents = createAccessChangeEvents(FullyQualifiedResourceId(resourceType.name, resourceId), LazyList.empty, persisted.accessPolicies)
Expand Down Expand Up @@ -867,7 +867,7 @@ class ResourceService(
case LoadResourceAuthDomainResult.NotConstrained =>
for {
_ <- accessPolicyDAO.setResourceParent(childResource, parentResource, samRequestContext)
_ <- AuditLogger.logAuditEventIO(samRequestContext, ResourceEvent(ResourceParentUpdated, childResource, Option(ResourceChange(parentResource))))
_ <- AuditLogger.logAuditEventIO(samRequestContext, ResourceEvent(ResourceParentUpdated, childResource, Set(ResourceChange(parentResource))))
} yield ()
case LoadResourceAuthDomainResult.Constrained(_) =>
IO.raiseError(
Expand All @@ -890,7 +890,7 @@ class ResourceService(
_ <- maybeOldParent.traverse { oldParent =>
for {
_ <- accessPolicyDAO.deleteResourceParent(resourceId, samRequestContext)
_ <- AuditLogger.logAuditEventIO(samRequestContext, ResourceEvent(ResourceParentRemoved, resourceId, Option(ResourceChange(oldParent))))
_ <- AuditLogger.logAuditEventIO(samRequestContext, ResourceEvent(ResourceParentRemoved, resourceId, Set(ResourceChange(oldParent))))
} yield ()
}
} yield maybeOldParent.isDefined
Expand Down
Loading