Problem/Motivation
If a user needs they TFA data reset or decryption is not working, provide drush command to reset (delete) a user's TFA data.
See also issue where bad TFA data cannot be decrypted. If only user on the site cannot get in, this is bad. #3157453: Decrypt and encrypt returns false
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | provide-drush-command-rest-user-tfa-data-3381701-2.patch | 4.56 KB | silverham |
Issue fork tfa-3381701
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
silverham commentedSee attached patch for 8.x-1.x version of this module.
Comment #3
silverham commentedComment #4
cmlaraAs this is a new feature, lets target it to 2.x first and than backport to 1.x. As a new feature this will need tests as well.
This constant is deprecated.
Per https://docs.drush.org/en/9.x/bootstrap/
"Commands supplied by Drupal modules are always @bootstrap full"
Has that changed in newer Drush versions?
Given this command can cause TFA to be disabled for a user I would prefer we not default to user 1 and instead error out.
Should this use dt() and placeholders as well?
This should use the context parameter and placeholders instead of concatenating.
$account->getEmail() can return NULL which could cause an error as mail() expects a string for $to.
Comment #7
bhanu951 commentedI have updated patch from #2 and addressed review feedback from #4 .
Comment #8
cmlaraComment #9
bhanu951 commentedI think it is ready to Merge. Any additional changes required?
Comment #10
silverham commentedThanks all for adjusting the patch and writing tests, I don't time/know how to do all these things. 🙂
Comment #11
bhanu951 commentedComment #13
cmlaraJust wanted to allow a bit of time for everyone who had worked on it to comment after I made the last minor commits changes based on MR feedback before committing. Sounds like everyone is good with it.
Automatic rebase on latest head, and committed to Dev. Thanks all who worked on this so far.
I see no reason not to consider this for 8.x-1.x as well, however it does not cleanly cherry-pick, setting PTBP for followup.
Comment #14
bhanu951 commentedComment #17
praneeth_22 commentedI have backported patch from mr59 to 8.x branch in mr62
Please review
Comment #18
cmlaraNW for code errors.
PHPUnit stage shows a declaration failure along with the code quality report shows methods being called with 3 parameters when 4 are required.
Comment #19
bhanu951 commentedI am just wondering why we are getting error on 8.x branch and not on 2.x branch, when the changes are same.
Comment #20
cmlaraDifference in the codebase, there has been a lot of refactoring since 8.x-1x
PHP Fatal error: Drupal\tfa\Commands\TfaTokenManagement and Drupal\tfa\TfaUserDataTrait define the same property ($userData) in the composition of Drupal\tfa\Commands\TfaTokenManagement. However, the definition differs and is considered incompatible. Class was composed in /builds/issue/tfa-3381701/web/modules/custom/tfa-3381701/src/Commands/TfaTokenManagement.php on line 20That is likely caused by the property promotion of the constructor clashing with the trait. We actually can’t use property promotion in 8.x-1.x as it’s a PHP8 only feature so we probably need to refactor that out anyways to use the older
$this->property = $passed_in_service;method.In 8.x-1.x the User Data service needs to be provided to the method as the fourth option, in 2.x it pulls from the property.
Comment #21
bhanu951 commentedI have backported patch to 8.x branch. But seems there is issue with logger channel argument passing in TfaTokenManagement Class.
I am getting below error when running drush command
If I try to add logger channel in tfa.services.yml files still getting above error.
If I add same code in drush.services.yml I am getting below error.
Comment #22
cmlaraIt should definitely be in the tfa.services.yml not the drush.services.yml for the logger service.
Just clearing the drush bin would probably not be enough as tfa.services.yml would be in the Drupal container not the Drush container.
Comment #23
bhanu951 commentedI have updated the service.yml file and the drush command is working as expected. Please re-review.
Comment #24
bhanu951 commented@cmlara I have made the required changes. Except few PHPStan errors which can be added to ignore list I think the MR #62 is ready.
Comment #25
bhanu951 commentedComment #26
cmlaraThanks for all the work,
Merged the backport to 8.x-1.x.