Skip to content
Snippets Groups Projects
Commit c71800d1 authored by Jaime Pérez's avatar Jaime Pérez
Browse files

Make the "check for updates" new feature configurable.

Add a configuration option named 'admin.checkforupdates' to enable or disable this feature.
parent cb373403
No related branches found
No related tags found
No related merge requests found
...@@ -76,9 +76,20 @@ $config = array( ...@@ -76,9 +76,20 @@ $config = array(
* You can also put a hash here; run "bin/pwgen.php" to generate one. * You can also put a hash here; run "bin/pwgen.php" to generate one.
*/ */
'auth.adminpassword' => '123', 'auth.adminpassword' => '123',
/*
* Set this options to true if you want to require administrator password to access the web interface
* or the metadata pages, respectively.
*/
'admin.protectindexpage' => false, 'admin.protectindexpage' => false,
'admin.protectmetadata' => false, 'admin.protectmetadata' => false,
/*
* Set this option to false if you don't want SimpleSAMLphp to check for new stable releases when
* visiting the configuration tab in the web interface.
*/
'admin.checkforupdates' => true,
/* /*
* Array of domains that are allowed when generating links or redirects * Array of domains that are allowed when generating links or redirects
* to URLs. SimpleSAMLphp will use this option to determine whether to * to URLs. SimpleSAMLphp will use this option to determine whether to
......
...@@ -70,30 +70,28 @@ $allLinks = array( ...@@ -70,30 +70,28 @@ $allLinks = array(
); );
SimpleSAML\Module::callHooks('frontpage', $allLinks); SimpleSAML\Module::callHooks('frontpage', $allLinks);
// get latest version // check for updates
$api_url = 'https://api.github.com/repos/simplesamlphp/simplesamlphp/releases'; if ($config->getBoolean('admin.checkforupdates', true)) {
$ch = curl_init($api_url.'/latest'); $api_url = 'https://api.github.com/repos/simplesamlphp/simplesamlphp/releases';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $ch = curl_init($api_url.'/latest');
curl_setopt($ch, CURLOPT_USERAGENT, 'SimpleSAMLphp'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 2); curl_setopt($ch, CURLOPT_USERAGENT, 'SimpleSAMLphp');
$response = curl_exec($ch); curl_setopt($ch, CURLOPT_TIMEOUT, 2);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
$latest = json_decode($response, true); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
$current = $config->getVersion(); $latest = json_decode($response, true);
if ($current !== 'master' && version_compare($current, ltrim($latest['tag_name'], 'v'), 'lt')) { $current = $config->getVersion();
$outdated = true; if ($current !== 'master' && version_compare($current, ltrim($latest['tag_name'], 'v'), 'lt')) {
$warnings[] = array( $outdated = true;
'{core:frontpage:warnings_outdated}', $warnings[] = array(
array('%LATEST_URL%' => $latest['html_url']) '{core:frontpage:warnings_outdated}',
); array('%LATEST_URL%' => $latest['html_url'])
);
}
} }
curl_close($ch);
} }
curl_close($ch);
$enablematrix = array( $enablematrix = array(
'saml20-idp' => $config->getBoolean('enable.saml20-idp', false), 'saml20-idp' => $config->getBoolean('enable.saml20-idp', false),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment