-
Notifications
You must be signed in to change notification settings - Fork 2
Show deprovisioning event and date in the audit log #635
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
base: main
Are you sure you want to change the base?
Changes from all commits
783a9a3
15a31b2
3ad99dd
c834623
4f34fa1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,7 +62,11 @@ public function handle(DomainMessage $domainMessage): void | |
|
|
||
| switch (true) { | ||
| case $event instanceof IdentityForgottenEvent: | ||
| // Don't insert the IdentityForgottenEvent into the audit log, as we'd remove it immediately afterwards. | ||
| // Record the deprovisioning entry first so applyIdentityForgottenEvent's re-query of | ||
| // findByIdentityId() picks it up too. The actor name is intentionally anonymized, | ||
| // consistent with all other entries for a forgotten identity. Anonymizing first | ||
| // would query before this entry exists, leaving its actor name untouched. | ||
| $this->applyAuditableEvent($event, $domainMessage); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backfilling via
Suggested approach: either make the projector skip creating an entry when one already exists for this identity + event, or replace the free-form backfill instruction with a one-shot, guarded console command (or SQL migration) that inserts only missing rows. At minimum, document the "run exactly once, before the new code starts projecting live events" constraint prominently — a checklist item in a test plan is not enough for a production runbook.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backfill suggestion will do |
||
| $this->applyIdentityForgottenEvent($event); | ||
| break; | ||
| // Finally apply the auditable event, most events are auditable this so first handle the unique variants | ||
|
|
@@ -79,6 +83,17 @@ public function handle(DomainMessage $domainMessage): void | |
| private function applyAuditableEvent(AuditableEvent $event, DomainMessage $domainMessage): void | ||
| { | ||
| $auditLogMetadata = $event->getAuditLogMetadata(); | ||
| $recordedOn = new DateTime(new CoreDateTime($domainMessage->getRecordedOn()->toString())); | ||
|
|
||
| if ($event instanceof IdentityForgottenEvent | ||
| && $this->auditLogRepository->hasDeprovisionedEntry( | ||
| $auditLogMetadata->identityId, | ||
| $event::class, | ||
| $recordedOn, | ||
| ) | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
| $metadata = $domainMessage->getMetadata()->serialize(); | ||
| $entry = new AuditLogEntry(); | ||
|
|
@@ -109,7 +124,7 @@ private function applyAuditableEvent(AuditableEvent $event, DomainMessage $domai | |
| $entry->identityId = (string)$auditLogMetadata->identityId; | ||
| $entry->identityInstitution = $auditLogMetadata->identityInstitution; | ||
| $entry->event = $event::class; | ||
| $entry->recordedOn = new DateTime(new CoreDateTime($domainMessage->getRecordedOn()->toString())); | ||
| $entry->recordedOn = $recordedOn; | ||
|
|
||
| if ($auditLogMetadata->secondFactorId instanceof SecondFactorId) { | ||
| $entry->secondFactorId = (string)$auditLogMetadata->secondFactorId; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IdentityRestoredEventhas no counterpart, so the log can end on "deprovisioned" for a live identityIdentity::restore()emitsIdentityRestoredEvent, but it is absent from both$eventActionMapandAuditLogRepository::$secondFactorEvents. After this change an identity that was forgotten and later restored shows a terminaldeprovisionedentry with nothing after it, which reads as "this account is gone" when it isn't. Pre-existing gap, but this change is what makes it visible.Suggested approach: consider adding
IdentityRestoredEvent::class => 'restored'to both maps in this PR (it needs an RA translation too, alongside the one already in OpenConext/Stepup-RA#531), or open a follow-up issue so it isn't lost.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kayjoosten sounds like out of scope? Can you check, maybe create new ticket and refine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope for this PR. Follow-up is tracked in #637: it covers adding the
IdentityRestoredEvent => restoredmapping, exposing it in the audit-log query allowlist, and lining that up with the RA-side translation work in OpenConext/Stepup-RA#531.