Added SAML-Toolkits php-saml to composer and installed it to the vendor folder. Implemented SSO with JumpCloud
🚀 Deploy website on push / 🎉 Deploy (push) Successful in 31s
🚀 Deploy website on push / 🎉 Deploy (push) Successful in 31s
Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
Vendored
+34
@@ -5,6 +5,7 @@ namespace api\user;
|
||||
use Firebase\JWT\JWT;
|
||||
use PDO;
|
||||
use function api\utils\dbConn;
|
||||
use function api\utils\getSAMLSettings;
|
||||
use function api\utils\getSecretKey;
|
||||
|
||||
require_once __DIR__ . "/../utils/config.php";
|
||||
@@ -138,5 +139,38 @@ class userData
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SAML settings
|
||||
* @return array - SAML settings
|
||||
*/
|
||||
public function getSamlConf(): array
|
||||
{
|
||||
return getSAMLSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the SAML user exists
|
||||
* @param string $username - Username
|
||||
* @param string $email - Email
|
||||
* @return bool - True if the user exists, false if not
|
||||
*/
|
||||
public function checkSAMLUser(string $username, string $email): bool
|
||||
{
|
||||
$conn = dbConn();
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = :username AND email = :email");
|
||||
$stmt->bindParam(":username", $username);
|
||||
$stmt->bindParam(":email", $email);
|
||||
$stmt->execute();
|
||||
|
||||
// set the resulting array to associative
|
||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user