19 declare(strict_types=1);
32 public function __construct(
string $authSourceName,
string $configurationPath)
36 SimpleSAML\Configuration::setConfigDir($configurationPath);
37 $this->config = SimpleSAML\Configuration::getInstance();
39 $storageType = $this->config->getString(
'store.type');
41 if (in_array($storageType, [
'phpsession',
''],
true)) {
42 throw new RuntimeException(
'Invalid SimpleSAMLphp session handler: Must not be phpsession or empty');
45 $this->authSource =
new SimpleSAML\Auth\Simple($authSourceName);
53 $templateHandler->
copy(
'./Services/Saml/lib/config.php.dist',
'auth/saml/config/config.php', [
54 'DB_PATH' => rtrim($configurationPath,
'/') .
'/ssphp.sq3',
55 'SQL_INITIAL_PASSWORD' =>
static function ():
string {
61 $templateHandler->copy(
'./Services/Saml/lib/authsources.php.dist',
'auth/saml/config/authsources.php', [
62 'RELAY_STATE' => rtrim(ILIAS_HTTP_PATH,
'/') .
'/saml.php',
63 'SP_ENTITY_ID' => rtrim(ILIAS_HTTP_PATH,
'/') .
'/Services/Saml/lib/metadata.php' 69 return $this->authSource->getAuthSource()->getAuthId();
74 $this->authSource->requireAuth();
79 $session = SimpleSAML\Session::getSessionFromRequest();
80 $session->setData(self::ILIAS, $key, $value);
85 $session = SimpleSAML\Session::getSessionFromRequest();
87 return $session->getData(self::ILIAS, $key);
92 $session = SimpleSAML\Session::getSessionFromRequest();
94 $session->deleteData(self::ILIAS, $key);
101 return $this->authSource->isAuthenticated();
106 return $this->authSource->getAttributes();
109 public function logout(
string $returnUrl =
''): void
114 'ReturnStateParam' =>
'LogoutState',
115 'ReturnStateStage' =>
'ilLogoutState' 118 if ($returnUrl !==
'') {
119 $params[
'ReturnTo'] = $returnUrl;
122 $this->authSource->logout(
$params);
132 return $this->authSource->getAuthDataArray();
copy(string $sourcePath, string $destinationPath, array $placeholders=[])
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
protectResource()
Protect a script resource with a SAML auth.
Class ChatMainBarProvider .
storeParam(string $key, $value)
__construct(string $authSourceName, string $configurationPath)
readonly SimpleSAML Configuration $config
static getBytes(int $length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
initConfigFiles(string $configurationPath)
Class ilSimpleSAMLphpConfigTemplateHandler.
readonly SimpleSAML Auth Simple $authSource
Class ilSimpleSAMLphpWrapper.
static clear(string $a_var)
Class ilSimpleSAMLphplIdpDiscovery.
logout(string $returnUrl='')