From 575d0bcaeaab9cd0c6b4a82c36b5db5435ed035b Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Mon, 9 Sep 2024 11:25:52 +1000 Subject: [PATCH] feat: ignore cors during connectivity check --- amd/build/connectivity_test.min.js | 2 +- amd/build/connectivity_test.min.js.map | 2 +- amd/src/connectivity_test.js | 8 ++++---- version.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/amd/build/connectivity_test.min.js b/amd/build/connectivity_test.min.js index ea6eebab3..27820f787 100644 --- a/amd/build/connectivity_test.min.js +++ b/amd/build/connectivity_test.min.js @@ -1,3 +1,3 @@ -define("auth_saml2/connectivity_test",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0;_exports.init=(checkTarget,redirURL)=>{const http=new XMLHttpRequest;http.open("HEAD",checkTarget),http.addEventListener("load",(()=>{window.location=redirURL})),http.send()}})); +define("auth_saml2/connectivity_test",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0;_exports.init=(checkTarget,redirURL)=>{fetch(checkTarget,{mode:"no-cors",method:"HEAD"}).then((()=>{window.location=redirURL}))}})); //# sourceMappingURL=connectivity_test.min.js.map \ No newline at end of file diff --git a/amd/build/connectivity_test.min.js.map b/amd/build/connectivity_test.min.js.map index 4c517b419..9630134f6 100644 --- a/amd/build/connectivity_test.min.js.map +++ b/amd/build/connectivity_test.min.js.map @@ -1 +1 @@ -{"version":3,"file":"connectivity_test.min.js","sources":["../src/connectivity_test.js"],"sourcesContent":["\n// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to check connectivity to IdP endpoint from client.\n *\n * @module auth_saml2/connectivity_test\n * @copyright 2023 Peter Burnett \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport const init = (checkTarget, redirURL) => {\n const http = new XMLHttpRequest();\n http.open('HEAD', checkTarget);\n http.addEventListener('load', () => {\n window.location = redirURL;\n });\n http.send();\n};\n"],"names":["checkTarget","redirURL","http","XMLHttpRequest","open","addEventListener","window","location","send"],"mappings":"iKAwBoB,CAACA,YAAaC,kBACxBC,KAAO,IAAIC,eACjBD,KAAKE,KAAK,OAAQJ,aAClBE,KAAKG,iBAAiB,QAAQ,KAC1BC,OAAOC,SAAWN,YAEtBC,KAAKM"} \ No newline at end of file +{"version":3,"file":"connectivity_test.min.js","sources":["../src/connectivity_test.js"],"sourcesContent":["\n// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to check connectivity to IdP endpoint from client.\n *\n * @module auth_saml2/connectivity_test\n * @copyright 2023 Peter Burnett \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport const init = (checkTarget, redirURL) => {\n // We need to use no-cors to ignore cors, however,\n // this means we are returned an opaque response.\n // But an opaque response is info to say if the site is accessible or not.\n fetch(checkTarget, { mode: 'no-cors', method: 'HEAD' }).then(() => {\n window.location = redirURL;\n });\n};\n"],"names":["checkTarget","redirURL","fetch","mode","method","then","window","location"],"mappings":"iKAwBoB,CAACA,YAAaC,YAI9BC,MAAMF,YAAa,CAAEG,KAAM,UAAWC,OAAQ,SAAUC,MAAK,KACzDC,OAAOC,SAAWN"} \ No newline at end of file diff --git a/amd/src/connectivity_test.js b/amd/src/connectivity_test.js index 3e484c26f..30a69f53f 100644 --- a/amd/src/connectivity_test.js +++ b/amd/src/connectivity_test.js @@ -23,10 +23,10 @@ */ export const init = (checkTarget, redirURL) => { - const http = new XMLHttpRequest(); - http.open('HEAD', checkTarget); - http.addEventListener('load', () => { + // We need to use no-cors to ignore cors, however, + // this means we are returned an opaque response. + // But an opaque response is info to say if the site is accessible or not. + fetch(checkTarget, { mode: 'no-cors', method: 'HEAD' }).then(() => { window.location = redirURL; }); - http.send(); }; diff --git a/version.php b/version.php index d8a820ae3..7c8fd47a0 100644 --- a/version.php +++ b/version.php @@ -24,8 +24,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024082000; // The current plugin version (Date: YYYYMMDDXX). -$plugin->release = 2024082000; // Match release exactly to version. +$plugin->version = 2024090900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->release = 2024090900; // Match release exactly to version. $plugin->requires = 2017051509; // Requires PHP 7, 2017051509 = T12. M3.3 // Strictly we require either Moodle 3.5 OR // we require Totara 3.3, but the version number