Commit 643ce809 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1579285: Fixing up auth/saml plugin config form



Gettting it to display missing dependencies better

behatnotneeded

Change-Id: I60c94456acb6ac864e087a190569e8b16a64dd4d
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 6e14878d
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -25,8 +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 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['errorbadlib'] = 'SimpleSAMLPHP library\'s "autoloader" file not found at %s.<br>Make sure you install SimpleSAMLphp via "make ssphp" and the file is readable.';
$string['errornomcrypt'] = 'PHP library "mcrypt" must be installed for auth/saml. Make sure you install and activate mcrypt eg:<br>sudo apt-get install php5-mcrypt<br>sudo php5enmod mcrypt<br>Then restart webserver.';
$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.';
@@ -41,7 +41,6 @@ $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';
+16 −16
Original line number Diff line number Diff line
@@ -380,18 +380,6 @@ 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',
@@ -401,10 +389,6 @@ 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,
@@ -455,6 +439,22 @@ class PluginAuthSaml extends PluginAuth {
                            ),
        );

        // check extensions are loaded
        $libchecks = '';
        if (!extension_loaded('mcrypt')) {
            $libchecks .= '<li>' . get_string('errornomcrypt','auth.saml') . '</li>';
        }
        if (!file_exists(get_config('docroot') .'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
            $libchecks .= '<li>' . get_string('errorbadlib','auth.saml', get_config('docroot') .'auth/saml/extlib/simplesamlphp/vendor/autoload.php') . '</li>';
        }
        if (!empty($libchecks)) {
            $libcheckstr = '<div class="alert alert-danger"><ul class="unstyled">' . $libchecks . '</ul></div>';
            $elements = array_merge(array('libchecks' => array(
                                                'type' => 'html',
                                                'value' => $libcheckstr,
                                     )), $elements);
        }

        return array(
            'class' => 'panel panel-body',
            'elements' => $elements,