Deprovision user's recovery methods - #636
Open
kayjoosten wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RecoveryTokenProjectoris 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, soRecoveryTokennever received theIdentityForgottenEventdispatch 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 theSecondFactorentities.RecoveryTokenProjectorwas 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 handlingIdentityForgottenEvent(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 errorsphpcs— no errorsphpunit -c ci/qa/phpunit.xml— 1134 tests passingphpunit -c ci/qa/phpunit.xml --testsuite=database— 8 tests passingIdentityTest), the collection accessor (RecoveryTokenCollectionTest), and forgetting an identity that has a recovery token (RightToBeForgottenCommandHandlerTest)