Skip to content

Commit

Permalink
Enable configuration of alternative authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Reijnders committed Sep 23, 2018
1 parent a839a14 commit f8dfab1
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 4 deletions.
2 changes: 2 additions & 0 deletions auth_config.php
Expand Up @@ -33,6 +33,8 @@
$res = db_query_one("update {$xerte_toolkits_site->database_table_prefix}sitedetails set authentication_method = 'Guest' where site_id=1");
}

$xerte_toolkits_site->altauthentication = "";

/*
* Note: see moodle_restrictions.php for additional Moodle specific options
*/
Expand Down
7 changes: 7 additions & 0 deletions index.php
Expand Up @@ -40,6 +40,13 @@

require_once(dirname(__FILE__) . "/website_code/php/login_library.php");

if ($xerte_toolkits_site->altauthentication != "" && isset($_GET['altauth']))
{
$xerte_toolkits_site->authentication_method = $xerte_toolkits_site->altauthentication;
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
$_SESSION['altauth'] = $xerte_toolkits_site->altauthentication;
}

login_processing();
login_processing2();

Expand Down
6 changes: 5 additions & 1 deletion library/Xerte/Authentication/Db/adduser.php
Expand Up @@ -21,7 +21,11 @@
{
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}

if ($xerte_toolkits_site->altauthentication != "" && isset($_SESSION['altauth']))
{
$xerte_toolkits_site->authentication_method = $xerte_toolkits_site->altauthentication;
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}
// Easy checks first
$mesg = "";
if (!isset($_POST['username']) || strlen($_POST['username']) == 0)
Expand Down
6 changes: 5 additions & 1 deletion library/Xerte/Authentication/Db/changepassword.php
Expand Up @@ -21,7 +21,11 @@
{
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}

if ($xerte_toolkits_site->altauthentication != "" && isset($_SESSION['altauth']))
{
$xerte_toolkits_site->authentication_method = $xerte_toolkits_site->altauthentication;
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}
// Easy checks first
$mesg = "";
if (!isset($_POST['username']) || strlen($_POST['username']) == 0)
Expand Down
6 changes: 5 additions & 1 deletion library/Xerte/Authentication/Db/deluser.php
Expand Up @@ -21,7 +21,11 @@
{
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}

if ($xerte_toolkits_site->altauthentication != "" && isset($_SESSION['altauth']))
{
$xerte_toolkits_site->authentication_method = $xerte_toolkits_site->altauthentication;
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}
// Easy checks first
$mesg = "";
if (!isset($_POST['username']) || strlen($_POST['username']) == 0)
Expand Down
6 changes: 5 additions & 1 deletion library/Xerte/Authentication/Db/moduser.php
Expand Up @@ -21,7 +21,11 @@
{
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}

if ($xerte_toolkits_site->altauthentication != "" && isset($_SESSION['altauth']))
{
$xerte_toolkits_site->authentication_method = $xerte_toolkits_site->altauthentication;
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}
// Easy checks first
$mesg = "";
$warn = "";
Expand Down
5 changes: 5 additions & 0 deletions library/Xerte/Authentication/Db/seluser.php
Expand Up @@ -21,6 +21,11 @@
{
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}
if ($xerte_toolkits_site->altauthentication != "" && isset($_SESSION['altauth']))
{
$xerte_toolkits_site->authentication_method = $xerte_toolkits_site->altauthentication;
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}

// Easy checks first
$mesg = "";
Expand Down
12 changes: 12 additions & 0 deletions management.php
Expand Up @@ -161,6 +161,12 @@ function mgt_page($xerte_toolkits_site, $extra)
{
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}
if (isset($_GET['altauth']))
{
$xerte_toolkits_site->authentication_method = 'Db';
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}

if (($_POST["login"] == $xerte_toolkits_site->admin_username) && ($_POST["password"] == $xerte_toolkits_site->admin_password)) {

$_SESSION['toolkits_logon_id'] = "site_administrator";
Expand Down Expand Up @@ -189,6 +195,12 @@ function mgt_page($xerte_toolkits_site, $extra)
echo "var site_url = \"" . $xerte_toolkits_site->site_url . "\";\n";

echo "var site_apache = \"" . $xerte_toolkits_site->apache . "\";\n";
if ($xerte_toolkits_site->altauthentication != "" && isset($_GET['altauth']))
{
$xerte_toolkits_site->authentication_method = $xerte_toolkits_site->altauthentication;
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
$_SESSION['altauth'] = $xerte_toolkits_site->altauthentication;
}

echo "var properties_ajax_php_path = \"website_code/php/properties/\";\n var management_ajax_php_path = \"website_code/php/management/\";\n var ajax_php_path = \"website_code/php/\";\n";
?></script>
Expand Down
6 changes: 6 additions & 0 deletions website_code/php/management/users.php
Expand Up @@ -30,6 +30,12 @@
{
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}
if ($xerte_toolkits_site->altauthentication != "" && isset($_SESSION['altauth']))
{
$xerte_toolkits_site->authentication_method = $xerte_toolkits_site->altauthentication;
$authmech = Xerte_Authentication_Factory::create($xerte_toolkits_site->authentication_method);
}

if ($authmech->check() && $authmech->canManageUser($jsscript))
{
echo "<h2>" . USERS_MANAGE_AUTH . "</h2>";
Expand Down

0 comments on commit f8dfab1

Please sign in to comment.