mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-10-22 18:18:07 +02:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23a6e44114 |
No files matched your search
@@ -276,6 +276,8 @@ class outagelib {
|
||||
// Since Moodle 4.3 cookiehttponly is default to true and this CFG is not set.
|
||||
// so if not set, default to true.
|
||||
$cookiehttponly = isset($CFG->cookiehttponly) ? (bool) $CFG->cookiehttponly : true;
|
||||
// SameSite=None lets the cookie accompany the IdP's cross-site POST back to the site.
|
||||
$cookiesamesite = $cookiesecure ? 'None' : 'Lax';
|
||||
|
||||
$code = <<<'EOT'
|
||||
<?php
|
||||
@@ -292,7 +294,14 @@ if ((time() >= {{STARTTIME}}) && (time() < {{STOPTIME}})) {
|
||||
$isphpunit = defined('PHPUNIT_TEST');
|
||||
|
||||
if (!empty($urlaccesskey) && !$isphpunit) {
|
||||
setcookie('auth_outage_accesskey', $urlaccesskey, time() + 86400, '/', '', {{COOKIESECURE}}, {{COOKIEHTTPONLY}});
|
||||
setcookie('auth_outage_accesskey', $urlaccesskey, [
|
||||
'expires' => time() + 86400,
|
||||
'path' => '/',
|
||||
'domain' => '',
|
||||
'secure' => {{COOKIESECURE}},
|
||||
'httponly' => {{COOKIEHTTPONLY}},
|
||||
'samesite' => {{COOKIESAMESITE}},
|
||||
]);
|
||||
}
|
||||
|
||||
// Use url access key if given, else the cookie, else null.
|
||||
@@ -347,11 +356,11 @@ if ((time() >= {{STARTTIME}}) && (time() < {{STOPTIME}})) {
|
||||
}
|
||||
EOT;
|
||||
$search = ['{{STARTTIME}}', '{{STOPTIME}}', '{{USEALLOWEDIPS}}', '{{ALLOWEDIPS}}', '{{USEACCESSKEY}}', '{{ACCESSKEY}}',
|
||||
'{{YOURIP}}', '{{COOKIESECURE}}', '{{COOKIEHTTPONLY}}', '{{METADATA}}'];
|
||||
'{{YOURIP}}', '{{COOKIESECURE}}', '{{COOKIEHTTPONLY}}', '{{COOKIESAMESITE}}', '{{METADATA}}'];
|
||||
// Note that var_export is required because (string) false == '', not 'false'.
|
||||
$replace = [$starttime, $stoptime, var_export(!empty($allowedips), true), $allowedips, var_export(!empty($accesskey), true),
|
||||
$accesskey, getremoteaddr('n/a'), var_export($cookiesecure, true),
|
||||
var_export($cookiehttponly, true), var_export($metadata, true)];
|
||||
var_export($cookiehttponly, true), var_export($cookiesamesite, true), var_export($metadata, true)];
|
||||
return str_replace($search, $replace, $code);
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,14 @@ if ((time() >= 123) && (time() < 456)) {
|
||||
$isphpunit = defined('PHPUNIT_TEST');
|
||||
|
||||
if (!empty($urlaccesskey) && !$isphpunit) {
|
||||
setcookie('auth_outage_accesskey', $urlaccesskey, time() + 86400, '/', '', true, false);
|
||||
setcookie('auth_outage_accesskey', $urlaccesskey, [
|
||||
'expires' => time() + 86400,
|
||||
'path' => '/',
|
||||
'domain' => '',
|
||||
'secure' => true,
|
||||
'httponly' => false,
|
||||
'samesite' => 'None',
|
||||
]);
|
||||
}
|
||||
|
||||
// Use url access key if given, else the cookie, else null.
|
||||
@@ -362,7 +369,14 @@ if ((time() >= 123) && (time() < 456)) {
|
||||
$isphpunit = defined('PHPUNIT_TEST');
|
||||
|
||||
if (!empty($urlaccesskey) && !$isphpunit) {
|
||||
setcookie('auth_outage_accesskey', $urlaccesskey, time() + 86400, '/', '', true, false);
|
||||
setcookie('auth_outage_accesskey', $urlaccesskey, [
|
||||
'expires' => time() + 86400,
|
||||
'path' => '/',
|
||||
'domain' => '',
|
||||
'secure' => true,
|
||||
'httponly' => false,
|
||||
'samesite' => 'None',
|
||||
]);
|
||||
}
|
||||
|
||||
// Use url access key if given, else the cookie, else null.
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = "auth_outage";
|
||||
$plugin->version = 2024081907; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = 2024081907; // Human-readable release information.
|
||||
$plugin->version = 2024081908; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = 2024081908; // Human-readable release information.
|
||||
$plugin->requires = 2017111309; // 2017111309 = T13, but this really requires 3.9 and higher.
|
||||
$plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!
|
||||
$plugin->supported = [39, 405]; // A range of branch numbers of supported moodle versions.
|
||||
|
||||
Reference in new issue
Block a user