Instructions copied from MDL-78511.
When it comes to testing, this resource for testing SMS sending in AWS will likely come in handy: https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html
Prerequisites
To test this issue you'll need a Moodle that you have admin access to.
You will need a resource for testing SMS sending in AWS.
Having an admin account makes it easier to move through all of the test settings.
If you don't have cli access to the instance make sure you have access to two separate admin accounts. As part of the testing will lock out a user.
Setup
More detailed setup instructions for MFA testing can be found in MDL-78509, the following setup are just the basics and there is some assumed knowledge.
Third party libraries
- Apply the patch and upgrade
- Login as admin.
- Navigate to: Site administration > plugins > administration tools > Multi-factor authentication
- Enable the "MFA plugin enabled" Checkbox
Set up your SMS Sandbox
- Access to https://signin.aws.amazon.com with your credentials.
- From your AWS Console go to Amazon SNS / Mobile / Text messaging(SMS) and enable it.
- Include some "Sandbox destination phone numbers"
- From Security credentials: create a new Access keys for this and save the "Key", "Secret" and Region for the configuration in Moodle.
More information about SMS sandbox can be found
Test third party libraries
- As admin, go to "Site administration" / "Development" / "Third party libraries
- Verify that the library "AWS SDK for PHP" exist.
- Verify that the library "JMESPath" exist.
Test Mobile phone SMS Authentication:
- Access to your Moodle as admin user.
- Go to "Admin tools" / "Multi-factor authentication" / "Mobile phone SMS"
- Enable the factor and include the AWS credentials created before
- Access to your user preferences / "Multi-factor authentication preferences"
- Set up "Mobile phone SMS" factor with a test phone number.
- Check you have received an SMS in your phone number
- Enter the code you received and continue.
- Open another browser and access to Moodle with your user
- Enter your username and password,
- Check a new screen will be display where it will ask for the Mobile phone SMS
- Check you have received an SMS in your mobile.
- Enter the code in the box and click on verify code
- Check you have been login successfully and you have access to Moodle.
NOTE: If you mess things up and locked yourself out, you can disable the whole MFA plugin from the CLI:
php admin/cli/cfg.php --component=tool_mfa --name=enabled --set=0 |
Note2: Reset user authentication factors
- Access to your Moodle as admin user
- Go to "Plugins" / Multi-factor authentication / Reset user authentication factors
- Search by one user with authentication factors
- Click on button "Reset user factor"
PHP Unit tests
Please run PHPUnit for admin/tool/mfa/factor/sms/tests/factor_test.php
for the MDK can use the below command:
mdk phpunit -r -u admin/tool/mfa/factor/sms/tests/factor_test.php |
Or
vendor/bin/phpunit admin/tool/mfa/factor/sms/tests/factor_test.php |