Commit 8637c117 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1579285: add checking about session handling and libs

behatnotneeded

Change-Id: I1ebba9adcd54852e426dd253016b978cbc27fa7d
parent c30d285b
......@@ -29,6 +29,27 @@ foreach ($metadata_files as $file) {
$metadata_sources[]= array('type' => 'xml', 'file' => $file);
}
// Fix up session handling config - to match Mahara
$memcache_config = array();
if (get_config('memcacheservers') || extension_loaded('memcache')) {
$sessionhandler = 'memcache';
$servers = get_config('memcacheservers');
if (empty($servers)) {
$servers = 'localhost';
}
$servers = explode(',', $servers);
foreach ($servers as $server) {
$url = parse_url($server);
$host = !empty($url['host']) ? $url['host'] : $url['path'];
$port = !empty($url['port']) ? $url['port'] : 11211;
$memcache_config[] = array('hostname' => $host, 'port'=> $port);
}
}
else {
$sessionhandler = 'phpsession';
}
/*
* The configuration of simpleSAMLphp
*
......@@ -377,11 +398,8 @@ $config = array (
*
* The default session handler is 'phpsession'.
*/
// 'session.handler' => 'phpsession',
'session.handler' => 'memcache',
// 'store.type' => 'phpsession',
// 'session.handler' => 'redis',
// 'store.type' => 'sessionJSON:Store',
'session.handler' => $sessionhandler,
/*
* Configuration for the MemcacheStore class. This allows you to store
......@@ -435,11 +453,10 @@ $config = array (
*
*/
'memcache_store.servers' => array(
array(
array('hostname' => 'localhost'),
),
$memcache_config,
),
/*
* This value is the duration data should be stored in memcache. Data
* will be dropped from the memcache servers when this time expires.
......@@ -466,6 +483,7 @@ $config = array (
),
'redis_store.expires' => 36 * (60*60), // 36 hours.
/*
* Should signing of generated metadata be enabled by default.
*
......
......@@ -39,10 +39,15 @@ require_once(get_config('libroot') .'institution.php');
if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
redirect();
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt','auth.saml'));
}
$sp = 'default-sp';
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
throw new AuthInstanceException(get_string('errorbadssphplib', 'auth.saml'));
throw new AuthInstanceException(get_string('errorbadlib', 'auth.saml', get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php'));
}
require_once(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php');
require_once(get_config('docroot') . 'auth/saml/extlib/_autoload.php');
......
......@@ -25,7 +25,8 @@ $string['errorbadssphpspentityid'] = 'Invalid Service Provider EntityId';
$string['errorretryexceeded'] = 'Maximum number of retries exceeded (%s) - there must be a problem with the identity service';
$string['errnosamluser'] = 'No user found';
$string['errorssphpsetup'] = 'SAML not set up correctly. Need to first run "make ssphp" from the commandline';
$string['errorbadlib'] = 'SimpleSAMLPHP lib directory %s is not correct.';
$string['errorbadlib'] = 'SimpleSAMLPHP lib directory autoloader %s does not exist. Make sure you install SimpleSAMLphp';
$string['errornomcrypt'] = 'library mcrypt must be installed for auth/saml. Make sure you install mcrypt eg: apt-get install php5-mcrypt. ';
$string['errorbadconfig'] = 'SimpleSAMLPHP config directory %s is incorrect.';
$string['errorbadcombo'] = 'You can only choose user auto-creation if you have not selected remoteuser.';
$string['errorbadmetadata'] = 'Badly formed SAML metadata. Ensure XML contains one valid IdP.';
......@@ -39,6 +40,8 @@ $string['noidpsfound'] = 'No IdPs found';
$string['institutionattribute'] = 'Institution attribute (contains "%s")';
$string['institutionidp'] = 'Institution IdP SAML Metadata';
$string['institutionvalue'] = 'Institution value to check against attribute';
$string['libchecks'] = 'Checking for correct libraries installed: %s';
$string['librariesinstalled'] = 'SimpleSAMLphp and mcrypt detected';
$string['link'] = 'Link accounts';
$string['linkaccounts'] = 'Do you want to link remote account %s with local account %s?';
$string['loginlink'] = 'Allow users to link own account';
......
......@@ -380,6 +380,18 @@ class PluginAuthSaml extends PluginAuth {
$interval = $datetime1->diff($datetime2);
$expirydays = $interval->format('%a');
// check extensions are loaded
$libchecks = '';
if (!extension_loaded('mcrypt')) {
$libchecks .= get_string('errornomcrypt','auth.saml');
}
if (!file_exists(get_config('docroot') .'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
$libchecks .= " " .get_string('errorbadlib','auth.saml', get_config('docroot') .'auth/saml/extlib/simplesamlphp/vendor/autoload.php');
}
$libchecks = (empty($libchecks) ? get_string('librariesinstalled','auth.saml') : '<span class="requiredmarker">'.$libchecks.'</span>');
$elements = array(
'authname' => array(
'type' => 'hidden',
......@@ -389,6 +401,10 @@ class PluginAuthSaml extends PluginAuth {
'type' => 'hidden',
'value' => 'saml',
),
'libchecks' => array(
'type' => 'html',
'value' => '<div><p>' . get_string('libchecks', 'auth.saml', $libchecks) . '</p></div>',
),
'spentityid' => array(
'type' => 'text',
'size' => 50,
......
......@@ -40,8 +40,12 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
redirect();
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
throw new AuthInstanceException(get_string('errorbadssphplib', 'auth.saml'));
throw new AuthInstanceException(get_string('errorbadlib', 'auth.saml', get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php'));
}
require_once(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php');
require_once(get_config('docroot') . 'auth/saml/extlib/_autoload.php');
......
......@@ -41,8 +41,12 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
redirect();
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
throw new AuthInstanceException(get_string('errorbadssphplib', 'auth.saml'));
throw new AuthInstanceException(get_string('errorbadlib', 'auth.saml', get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php'));
}
require_once(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php');
require_once(get_config('docroot') . 'auth/saml/extlib/_autoload.php');
......
......@@ -40,8 +40,12 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
redirect();
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
throw new AuthInstanceException(get_string('errorbadssphplib', 'auth.saml'));
throw new AuthInstanceException(get_string('errorbadlib', 'auth.saml', get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php'));
}
require_once(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php');
require_once(get_config('docroot') . 'auth/saml/extlib/_autoload.php');
......
......@@ -40,8 +40,12 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
redirect();
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
throw new AuthInstanceException(get_string('errorbadssphplib', 'auth.saml'));
throw new AuthInstanceException(get_string('errorbadlib', 'auth.saml', get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php'));
}
require_once(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php');
require_once(get_config('docroot') . 'auth/saml/extlib/_autoload.php');
......
......@@ -40,8 +40,12 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
redirect();
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
throw new AuthInstanceException(get_string('errorbadssphplib', 'auth.saml'));
throw new AuthInstanceException(get_string('errorbadlib', 'auth.saml', get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php'));
}
require_once(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php');
require_once(get_config('docroot') . 'auth/saml/extlib/_autoload.php');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment