saml enable - initial testing
This commit is contained in:
@@ -39,5 +39,7 @@ class Registry { const
|
||||
DEFAULTLANGUAGE = 'en', // Default language - make sure a translation file exists
|
||||
ROWSPERPAGE = '10', // Rows per page on tables (does not include reports)
|
||||
MINPASS = '8', // Minimum password length
|
||||
DEFAULTTZ = 'America/New_York' // DEFAULT TIME ZONE
|
||||
DEFAULTTZ = 'America/New_York', // DEFAULT TIME ZONE
|
||||
AUTHMETHOD = 'INTERNAL', // Auth users using INTERNAL or SAML
|
||||
AUTHIDP = 'default-sp' // Identity Provider if using SAML
|
||||
;}
|
||||
|
||||
@@ -26,6 +26,30 @@ use App\LobbySIO\Config\Registry;
|
||||
* @author josh.north
|
||||
*/
|
||||
class Users {
|
||||
// Get user info as array by user id. Pass % for all.
|
||||
public function getUserInfoByEmail($useremail, $rowsperpage, $offset) {
|
||||
if ($rowsperpage == "%") { $cond_rowsperpage = NULL; } else { $cond_rowsperpage = " LIMIT " . Registry::ROWSPERPAGE; };
|
||||
if ($offset == "%") { $cond_offset = NULL; } else { $cond_offset = " OFFSET " . $offset; };
|
||||
$query = "
|
||||
SELECT
|
||||
" . Registry::DB_PRFX . "users.id as users_id,
|
||||
" . Registry::DB_PRFX . "users.username as users_username,
|
||||
" . Registry::DB_PRFX . "users.email as users_email,
|
||||
" . Registry::DB_PRFX . "users.created as users_created,
|
||||
" . Registry::DB_PRFX . "users.firstname as users_firstname,
|
||||
" . Registry::DB_PRFX . "users.lastname as users_lastname,
|
||||
" . Registry::DB_PRFX . "users.usertype as users_usertypeid,
|
||||
" . Registry::DB_PRFX . "usertypes.name as users_usertype,
|
||||
" . Registry::DB_PRFX . "users.password as users_password
|
||||
FROM " . Registry::DB_PRFX . "users
|
||||
INNER JOIN " . Registry::DB_PRFX . "usertypes ON " . Registry::DB_PRFX . "users.usertype = " . Registry::DB_PRFX . "usertypes.id
|
||||
WHERE " . Registry::DB_PRFX . "users.email LIKE \"$useremail\"
|
||||
ORDER BY " . Registry::DB_PRFX . "users.lastname ASC" . $cond_rowsperpage . $cond_offset;
|
||||
$database = new \App\LobbySIO\Database\Connect();
|
||||
$rows = $database->getQuery($query);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
// Get user info as array by user id. Pass % for all.
|
||||
public function getUserInfo($userid, $rowsperpage, $offset) {
|
||||
if ($rowsperpage == "%") { $cond_rowsperpage = NULL; } else { $cond_rowsperpage = " LIMIT " . Registry::ROWSPERPAGE; };
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
namespace App\LobbySIO\Misc;
|
||||
use App\LobbySIO\Config\Registry;
|
||||
use SimpleSAML\Auth\Simple;
|
||||
|
||||
/**
|
||||
* Miscellaneous junk probably not even deserving of a class but whatever
|
||||
@@ -94,12 +95,28 @@ class StaticFunctions {
|
||||
}
|
||||
|
||||
public function getSessionStatus () {
|
||||
if (!isset($_SESSION['user_id']) || !isset($_SESSION['signature']) || !isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] != true || $_SESSION['signature'] != md5($_SESSION['user_id'] . $_SERVER['HTTP_USER_AGENT'])) {
|
||||
if (!isset($_SESSION['user_id']) || !isset($_SESSION['signature']) || !isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] != true || $_SESSION['signature'] != md5($_SESSION['user_id'] . filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'))) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserSessionStatus () {
|
||||
if (Registry::AUTHMETHOD === "INTERNAL") {
|
||||
if (!isset($_SESSION['user_id']) || !isset($_SESSION['signature']) || !isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] != true || $_SESSION['signature'] != md5($_SESSION['user_id'] . filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'))) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} elseif (Registry::AUTHMETHOD === "SAML") {
|
||||
$auth = new \SimpleSAML\Auth\Simple(Registry::AUTHIDP);
|
||||
if (!$auth->isAuthenticated()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user