19declare(strict_types=1);
27 protected SimpleSAML\Configuration
$config;
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();
99 $session = SimpleSAML\Session::getSessionFromRequest();
109 $session = SimpleSAML\Session::getSessionFromRequest();
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();
static getBytes(int $length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
static set(string $a_var, $a_val)
Set a value.
Class ilSimpleSAMLphpConfigTemplateHandler.
Class ilSimpleSAMLphpWrapper.
__construct(string $authSourceName, string $configurationPath)
initConfigFiles(string $configurationPath)
popParam(string $key)
mixed
protectResource()
Protect a script resource with a SAML auth.
logout(string $returnUrl='')
storeParam(string $key, $value)
SimpleSAML Auth Simple $authSource
getParam(string $key)
mixed
getAuthDataArray()
@inheritDoc
SimpleSAML Configuration $config
getIdpDiscovery()
ilSamlIdpDiscovery
Class ilSimpleSAMLphplIdpDiscovery.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params