Merge branch 'MDL-65075-master' of git://github.com/jleyva/moodle
authorAdrian Greeve <abgreeve@gmail.com>
Tue, 9 Apr 2019 09:12:46 +0000 (17:12 +0800)
committerAdrian Greeve <abgreeve@gmail.com>
Tue, 9 Apr 2019 09:16:18 +0000 (17:16 +0800)
1  2 
admin/tool/mobile/classes/external.php

@@@ -286,6 -286,13 +286,12 @@@ class external extends external_api 
              }
          }
  
 -
+         // Only requests from the Moodle mobile or desktop app. This enhances security to avoid any type of XSS attack.
+         // This code goes intentionally here and not inside the check_autologin_prerequisites() function because it
+         // is used by other PHP scripts that can be opened in any browser.
+         if (!\core_useragent::is_moodle_app()) {
+             throw new moodle_exception('apprequired', 'tool_mobile');
+         }
          api::check_autologin_prerequisites($USER->id);
  
          if (isset($_GET['privatetoken']) or empty($privatetoken)) {