Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-80736

Move AWS helper code to core namespace

XMLWordPrintable

    • MOODLE_404_STABLE
    • MOODLE_404_STABLE
    • MDL-80736_main
    • Hide

      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 

      1. Apply the patch and upgrade
      2. Login as admin.
      3. Navigate to: Site administration > plugins > administration tools > Multi-factor authentication
      4. Enable the "MFA plugin enabled" Checkbox

      Set up your SMS Sandbox

      1. Access to https://signin.aws.amazon.com with your credentials.
      2. From your AWS Console go to Amazon SNS / Mobile / Text messaging(SMS) and enable it.
      3. Include some "Sandbox destination phone numbers"
      4. 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

      1. As admin, go to "Site administration" / "Development" / "Third party libraries
      2. Verify that the library "AWS SDK for PHP" exist. 
      3. Verify that the library "JMESPath" exist. 

      Test Mobile phone SMS Authentication:

      1. Access to your Moodle as admin user.
      2. Go to "Admin tools" / "Multi-factor authentication" / "Mobile phone SMS"
      3. Enable the factor and include the AWS credentials created before
      4. Access to your user preferences / "Multi-factor authentication preferences"
      5. Set up "Mobile phone SMS" factor with a test phone number.
      6. Check you have received an SMS in your phone number
      7. Enter the code you received and continue. 
      8. Open another browser and access to Moodle with your user 
      9. Enter your username and password, 
      10. Check a new screen will be display where it will ask for the Mobile phone SMS
      11. Check you have received an SMS in your mobile. 
      12. Enter the code in the box and click on verify code
      13. 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

      1. Access to your Moodle as admin user
      2. Go to "Plugins" / Multi-factor authentication / Reset user authentication factors
      3. Search by one user with authentication factors
      4. 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

       

      Show
      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  https://aws.amazon.com/blogs/compute/introducing-the-sms-sandbox-for-amazon-sns/ https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox-verifying-phone-numbers.html https://docs.aws.amazon.com/sns/latest/dg/sns-getting-started.html 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  

      To support the use of SMS for an MFA factor, the AWS SDK has been included in core at lib/aws-sdk.

      To make this easier, some code has been ported from Catalyst's local_aws plugin (aws_helper.php, client_factory.php and admin_settings_aws_region.php). However, this has been put inside factor_sms plugin, making it ugly (and according to the inter-component communication policy, illegal) for other plugins to use these helpers.

      It would be nice if these could be moved to a core namespace (core\aws?) so that they can be used by other plugins.

        1. phpunit.png
          phpunit.png
          33 kB
        2. step_10.png
          step_10.png
          60 kB
        3. step_11.jpg
          step_11.jpg
          47 kB
        4. step_13.png
          step_13.png
          72 kB
        5. step_2_3_third_party_lib.png
          step_2_3_third_party_lib.png
          120 kB
        6. step_6.jpg
          step_6.jpg
          27 kB

            marxjohnson Mark Johnson
            marxjohnson Mark Johnson
            Sarah Cotton Sarah Cotton
            Huong Nguyen Huong Nguyen
            Safat Shahin Safat Shahin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 45 minutes
                45m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.