19 declare(strict_types=1);
30 public function __construct(
string $authSourceName,
string $configurationPath)
34 SimpleSAML\Configuration::setConfigDir($configurationPath);
35 $this->config = SimpleSAML\Configuration::getInstance();
37 $sessionHandler = $this->config->getString(
'session.handler',
false);
38 $storageType = $this->config->getString(
'store.type',
false);
41 $storageType ===
'phpsession' || $sessionHandler ===
'phpsession' ||
42 (empty($storageType) && empty($sessionHandler))
44 throw new RuntimeException(
'Invalid SimpleSAMLphp session handler: Must not be phpsession or empty');
47 $this->authSource =
new SimpleSAML\Auth\Simple($authSourceName);
55 $templateHandler->
copy(
'./Services/Saml/lib/config.php.dist',
'auth/saml/config/config.php', [
56 'DB_PATH' => rtrim($configurationPath,
'/') .
'/ssphp.sq3',
57 'SQL_INITIAL_PASSWORD' =>
static function ():
string {
63 $templateHandler->copy(
'./Services/Saml/lib/authsources.php.dist',
'auth/saml/config/authsources.php', [
64 'RELAY_STATE' => rtrim(ILIAS_HTTP_PATH,
'/') .
'/saml.php',
65 'SP_ENTITY_ID' => rtrim(ILIAS_HTTP_PATH,
'/') .
'/Services/Saml/lib/metadata.php' 74 return $this->authSource->getAuthSource()->getAuthId();
82 $this->authSource->requireAuth();
90 $session = SimpleSAML\Session::getSessionFromRequest();
91 $session->setData(
'ilias', $key, $value);
99 $session = SimpleSAML\Session::getSessionFromRequest();
101 return $session->getData(
'ilias', $key);
109 $session = SimpleSAML\Session::getSessionFromRequest();
111 $session->deleteData(
'ilias', $key);
121 return $this->authSource->isAuthenticated();
129 return $this->authSource->getAttributes();
135 public function logout(
string $returnUrl =
''): void
140 'ReturnStateParam' =>
'LogoutState',
141 'ReturnStateStage' =>
'ilLogoutState' 144 if ($returnUrl !==
'') {
145 $params[
'ReturnTo'] = $returnUrl;
148 $this->authSource->logout(
$params);
164 return $this->authSource->getAuthDataArray();
SimpleSAML Configuration $config
copy(string $sourcePath, string $destinationPath, array $placeholders=[])
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
protectResource()
Protect a script resource with a SAML auth.
popParam(string $key)
mixed
storeParam(string $key, $value)
__construct(string $authSourceName, string $configurationPath)
SimpleSAML Auth Simple $authSource
getIdpDiscovery()
ilSamlIdpDiscovery
static getBytes(int $length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
initConfigFiles(string $configurationPath)
Class ilSimpleSAMLphpConfigTemplateHandler.
Class ilSimpleSAMLphpWrapper.
getParam(string $key)
mixed
Class ilSimpleSAMLphplIdpDiscovery.
static set(string $a_var, $a_val)
Set a value.
logout(string $returnUrl='')