Skip to content

Show deprovisioning event and date in the audit log - #635

Open
kayjoosten wants to merge 2 commits into
mainfrom
feature/issue-423-deprovisioning-audit-log
Open

Show deprovisioning event and date in the audit log#635
kayjoosten wants to merge 2 commits into
mainfrom
feature/issue-423-deprovisioning-audit-log

Conversation

@kayjoosten

Copy link
Copy Markdown
Contributor

Why is this change needed?

Prior to this change, deprovisioning an identity via the lifecycle API left no trace in the audit log. AuditLogProjector explicitly skipped writing an entry for IdentityForgottenEvent, so RA(A)s had no way to see that, or when, an identity had been deprovisioned.

How does it address the issue?

Maps IdentityForgottenEvent to a new deprovisioned audit log action, and reorders AuditLogProjector::handle() so the deprovisioning entry is persisted before the identity's other audit log entries are anonymized; otherwise the newly created entry would be wiped immediately after. A projector test covers both the new entry and the existing anonymization behavior.

The RA-side rendering of this new action (translation for "Deprovisioned") is in OpenConext/Stepup-RA#531 — the audit log template there already renders any action generically, so no other RA change was needed.

Retroactive backfill

The issue asks for the audit log projection of already-deprovisioned identities to be updated too. This doesn't need new code: operators can backfill via the existing replay tooling once this is deployed:

bin/console stepup:event:replay

Select IdentityForgottenEvent and the AuditLogProjector when prompted. This re-dispatches all past IdentityForgottenEvents through the projector, creating the missing deprovisioned entries for already-deprovisioned identities.

Provide links to any relevant tickets, articles or other resources
Closes OpenConext/Stepup-RA#423

Test plan

  • php vendor/bin/phpunit -c ci/qa/phpunit.xml --filter AuditLogProjectorTest — 4/4 passing
  • ./ci/qa/phpcs — clean
  • phpstan — no new errors (206 pre-existing errors, none touching AuditLog*)
  • After deploy: run stepup:event:replay in an environment with already-deprovisioned identities, confirm deprovisioned entries appear with correct date/time

Why is this change needed?
Prior to this change, deprovisioning an identity via the lifecycle API left no
trace in the audit log. AuditLogProjector explicitly skipped writing an entry
for IdentityForgottenEvent, so RA(A)s had no way to see that, or when, an
identity had been deprovisioned.

How does it address the issue?
This change maps IdentityForgottenEvent to a new 'deprovisioned' audit log
action and reorders AuditLogProjector::handle() so the deprovisioning entry
is persisted before the identity's other audit log entries are anonymized;
otherwise the newly created entry would be wiped immediately after. A
projector test covers both the new entry and the existing anonymization
behavior.

Provide links to any relevant tickets, articles or other resources
OpenConext/Stepup-RA#423
Why is this change needed?
IdentityForgottenEvent was mapped to a new 'deprovisioned' audit log
action and persisted, but AuditLogRepository::createSecondFactorSearchQuery()
filters entries against an event allowlist that never included it, so the
new entry was written but silently filtered out of the RA audit log page.
Separately, the comment justifying the projector's insert-before-anonymise
ordering had the mechanism backwards, and the projector test mocked
findByIdentityId() to omit the just-inserted entry, so it couldn't have
caught either issue.

How does it address the issue?
Adds IdentityForgottenEvent::class to the allowlist so the entry is
actually returned to the RA UI. Corrects the ordering comment: inserting
before anonymising means the new entry is included in the same
anonymisation pass as the identity's other entries (its actor name gets
wiped like everything else), not preserved as the old comment claimed.
Updates the test to mock findByIdentityId() the way the real repository
behaves (returning the freshly flushed entry alongside the pre-existing
one), and asserts the new entry's actor name is anonymised too.

Provide links to any relevant tickets, articles or other resources
OpenConext/Stepup-RA#423
@kayjoosten

Copy link
Copy Markdown
Contributor Author

Update after code review: the initial version wrote the `deprovisioned` entry but `AuditLogRepository::createSecondFactorSearchQuery()` filters against an event allowlist that didn't include `IdentityForgottenEvent`, so it was silently dropped from the RA audit log query — the feature was a no-op. Fixed in the latest commit, along with a corrected (previously backwards) code comment and a test that now mocks `findByIdentityId()` the way the real repository behaves (returning the freshly flushed entry, not omitting it).

Also worth calling out explicitly: `stepup:event:replay` is not idempotent (new UUID per replayed entry), so the retroactive backfill described above should only be run once per environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show deprovisioning event in audit log

1 participant