mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-09-07 00:06:01 +02:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0da0542663 | ||
|
|
a093165caf | ||
|
|
85d0657563 | ||
|
|
88667c51e4 | ||
|
|
5dd73b0909 | ||
|
|
1a94b8e635 |
@@ -53,10 +53,14 @@ class infopage {
|
||||
$CFG->svgicons = true;
|
||||
|
||||
if (is_null($params)) {
|
||||
$id = optional_param('id', null, PARAM_INT);
|
||||
$params = [
|
||||
'id' => optional_param('id', null, PARAM_INT),
|
||||
'id' => $id,
|
||||
'outage' => null,
|
||||
'static' => optional_param('static', false, PARAM_BOOL),
|
||||
'static' => !is_null($id) && hash_equals(
|
||||
self::statickey($id),
|
||||
optional_param('statickey', '', PARAM_ALPHANUM)
|
||||
),
|
||||
];
|
||||
} else {
|
||||
$defaults = [
|
||||
@@ -152,4 +156,21 @@ class infopage {
|
||||
$this->outage = $params['outage'];
|
||||
$this->static = $params['static'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the secret token that proves a request to view an outage's static
|
||||
* rendering came from this plugin's own static-page generator, not an external
|
||||
* client forging the request. Used to gate the 'static' flag (see constructor).
|
||||
*
|
||||
* @param int $outageid
|
||||
* @return string
|
||||
*/
|
||||
public static function statickey($outageid) {
|
||||
$secret = get_config('auth_outage', 'staticsecret');
|
||||
if (empty($secret)) {
|
||||
$secret = random_string(64);
|
||||
set_config('staticsecret', $secret, 'auth_outage');
|
||||
}
|
||||
return hash_hmac('sha256', (string)$outageid, $secret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,8 @@ class maintenance_static_page {
|
||||
header('X-Outage-EndTime: ' . $outage->stoptime);
|
||||
}
|
||||
$data = maintenance_static_page_io::file_get_data(
|
||||
$CFG->wwwroot . '/auth/outage/info.php?auth_outage_hide_warning=1&static=1&id=' . $outage->id
|
||||
$CFG->wwwroot . '/auth/outage/info.php?auth_outage_hide_warning=1&id=' . $outage->id
|
||||
. '&statickey=' . infopage::statickey($outage->id)
|
||||
);
|
||||
$html = $data['contents'];
|
||||
}
|
||||
|
||||
@@ -267,6 +267,10 @@ class outagelib {
|
||||
// single-quotes (and double for the sake of it) are present otherwise it would break the code.
|
||||
$allowedips = addslashes($allowedips);
|
||||
|
||||
// Escape the access key before substitution into the PHP literal to prevent
|
||||
// code injection via a maliciously crafted access key value.
|
||||
$accesskey = addslashes((string)$accesskey);
|
||||
|
||||
$cookiesecure = is_moodle_cookie_secure();
|
||||
|
||||
// Since Moodle 4.3 cookiehttponly is default to true and this CFG is not set.
|
||||
|
||||
@@ -30,7 +30,11 @@ use auth_outage\local\controllers\maintenance_static_page;
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
require_once(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
admin_externalpage_setup('auth_outage_manage');
|
||||
|
||||
$id = optional_param('id', null, PARAM_INT);
|
||||
$outage = is_null($id) ? outagedb::get_next_starting() : outagedb::get_by_id($id);
|
||||
if (is_null($outage)) {
|
||||
|
||||
@@ -95,6 +95,9 @@ abstract class base_testcase extends \advanced_testcase {
|
||||
|
||||
parent::setUp();
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// These tests rely on force login being disabled, but Moodle 5.2 enables it by default (MDL-87523).
|
||||
set_config('forcelogin', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = "auth_outage";
|
||||
$plugin->version = 2026011304; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = 2026011304; // Human-readable release information.
|
||||
$plugin->version = 2026011307; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = 2026011307; // Human-readable release information.
|
||||
$plugin->requires = 2025100600; // Moodle 5.1.
|
||||
$plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!
|
||||
$plugin->supported = [501, 501]; // A range of branch numbers of supported moodle versions.
|
||||
|
||||
@@ -39,7 +39,15 @@ defined('MOODLE_INTERNAL') || die();
|
||||
<b><?php echo get_string('infountil', 'auth_outage'); ?></b>
|
||||
<?php echo userdate($viewbag['outage']->stoptime, get_string('datetimeformat', 'auth_outage')); ?>
|
||||
</div>
|
||||
<div class="auth_outage_info_description"><?php echo $viewbag['outage']->get_description(); ?></div>
|
||||
<div class="auth_outage_info_description">
|
||||
<?php
|
||||
echo format_text(
|
||||
$viewbag['outage']->get_description(),
|
||||
FORMAT_HTML,
|
||||
['context' => context_system::instance()]
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if ($viewbag['admin']) : ?>
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user