Skip to content

Deprovision user's recovery methods - #636

Open
kayjoosten wants to merge 1 commit into
mainfrom
feature/issue-628-deprovision-recovery-tokens
Open

Deprovision user's recovery methods#636
kayjoosten wants to merge 1 commit into
mainfrom
feature/issue-628-deprovision-recovery-tokens

Conversation

@kayjoosten

Copy link
Copy Markdown
Contributor

Summary

  • Forgetting an identity (used by the deprovisioning flow) now cascades to its recovery tokens the same way it already cascades to second factors.
  • RecoveryTokenProjector is now tagged for event replay so older forgotten identities can be backfill-cleaned using the existing replay tooling.

Details

Identity::getChildEntities() included the second-factor and registration-authority collections but not recovery tokens, so RecoveryToken never received the IdentityForgottenEvent dispatch that gets cascaded to child entities. The read-model projector already cleaned up recovery-token rows on forget, but the write-model side was inconsistent with the SecondFactor entities.

RecoveryTokenProjector was also never tagged for event replay, so there was no way to actually run a backfill for recovery-token rows belonging to identities forgotten before the projector started handling IdentityForgottenEvent (2022-07-13). That's now tagged, and documented as a one-time operational step in the changelog.

Closes #628

Test plan

  • phpstan analyse -c ci/qa/phpstan.neon — no errors
  • phpcs — no errors
  • phpunit -c ci/qa/phpunit.xml — 1134 tests passing
  • phpunit -c ci/qa/phpunit.xml --testsuite=database — 8 tests passing
  • New unit tests cover the child-entity dispatch (IdentityTest), the collection accessor (RecoveryTokenCollectionTest), and forgetting an identity that has a recovery token (RightToBeForgottenCommandHandlerTest)

If applied, this commit will make forgetting an identity (used by the
deprovisioning flow) cascade to its recovery tokens the same way it
already cascades to second factors, and ensure the documented backfill
path for older forgotten identities actually works.

Why is this change needed?
Prior to this change, Identity::getChildEntities() included the
second-factor and registration-authority collections but not recovery
tokens, so RecoveryToken never received the IdentityForgottenEvent
dispatch that Broadway cascades to child entities. The read-model
projector already cleaned up recovery-token rows on forget, but the
write-model side was inconsistent with the SecondFactor entities.
Additionally, RecoveryTokenProjector was never tagged for event
replay, so the documented one-time backfill for identities forgotten
before the projector handled IdentityForgottenEvent could not
actually be run.

How does it address the issue?
- Adds RecoveryToken::applyIdentityForgottenEvent() (a no-op, since a
  RecoveryToken only holds a token id and type, no PII) purely so the
  entity participates in the cascade like the other child entities.
- Adds RecoveryTokenCollection::getValues() and wires it into
  Identity::getChildEntities(), mirroring the existing
  SecondFactorCollection/RegistrationAuthorityCollection pattern.
- Tags RecoveryTokenProjector with projector.register_for_replay so
  it can be selected by the stepup:event:replay console command.
- Adds a phpstan baseline entry for the new nullable-collection
  access, following the existing pattern used for the other
  collections on Identity.
- Adds unit tests proving the cascade actually reaches RecoveryToken
  (IdentityTest), that RecoveryTokenCollection::getValues() returns
  all tokens (RecoveryTokenCollectionTest), and that an identity with
  a recovery token can be forgotten end to end
  (RightToBeForgottenCommandHandlerTest).
- Documents the required one-time operational backfill step in
  CHANGELOG.md, with the correct historical cutoff commit and the
  prod_event_replay environment required to run it.

Links / references:
#628
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.

Deprovision user's recovery methods

1 participant