ILIAS  release_8 Revision v8.24
ilSimpleSAMLphpWrapper Class Reference

Class ilSimpleSAMLphpWrapper. More...

+ Inheritance diagram for ilSimpleSAMLphpWrapper:
+ Collaboration diagram for ilSimpleSAMLphpWrapper:

Public Member Functions

 __construct (string $authSourceName, string $configurationPath)
 
 getAuthId ()
 
Returns
string
More...
 
 protectResource ()
 Protect a script resource with a SAML auth. More...
 
 storeParam (string $key, $value)
 
Parameters
string$key
mixed$value
More...
 
 getParam (string $key)
 
Parameters
string$key
Returns
mixed
More...
 
 popParam (string $key)
 
Parameters
string$key
Returns
mixed
More...
 
 isAuthenticated ()
 
Returns
bool
More...
 
 getAttributes ()
 
Returns
array
More...
 
 logout (string $returnUrl='')
 
Parameters
string$returnUrl
More...
 
 getIdpDiscovery ()
 
Returns
ilSamlIdpDiscovery
More...
 
 getAuthDataArray ()
 @inheritDoc More...
 
 getAuthId ()
 
 protectResource ()
 Protect a script resource with a SAML auth. More...
 
 storeParam (string $key, $value)
 
 isAuthenticated ()
 
 popParam (string $key)
 
 getParam (string $key)
 
 getAttributes ()
 
 logout (string $returnUrl='')
 
 getIdpDiscovery ()
 
 getAuthDataArray ()
 

Protected Member Functions

 initConfigFiles (string $configurationPath)
 

Protected Attributes

SimpleSAML Configuration $config
 
SimpleSAML Auth Simple $authSource
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSimpleSAMLphpWrapper::__construct ( string  $authSourceName,
string  $configurationPath 
)

Definition at line 30 of file class.ilSimpleSAMLphpWrapper.php.

31 {
32 $this->initConfigFiles($configurationPath);
33
34 SimpleSAML\Configuration::setConfigDir($configurationPath);
35 $this->config = SimpleSAML\Configuration::getInstance();
36
37 $sessionHandler = $this->config->getString('session.handler', false);
38 $storageType = $this->config->getString('store.type', false);
39
40 if (
41 $storageType === 'phpsession' || $sessionHandler === 'phpsession' ||
42 (empty($storageType) && empty($sessionHandler))
43 ) {
44 throw new RuntimeException('Invalid SimpleSAMLphp session handler: Must not be phpsession or empty');
45 }
46
47 $this->authSource = new SimpleSAML\Auth\Simple($authSourceName);
48 }
initConfigFiles(string $configurationPath)

References initConfigFiles().

+ Here is the call graph for this function:

Member Function Documentation

◆ getAttributes()

ilSimpleSAMLphpWrapper::getAttributes ( )

Returns
array

Implements ilSamlAuth.

Definition at line 127 of file class.ilSimpleSAMLphpWrapper.php.

127 : array
128 {
129 return $this->authSource->getAttributes();
130 }

◆ getAuthDataArray()

ilSimpleSAMLphpWrapper::getAuthDataArray ( )

@inheritDoc

Implements ilSamlAuth.

Definition at line 162 of file class.ilSimpleSAMLphpWrapper.php.

162 : array
163 {
164 return $this->authSource->getAuthDataArray();
165 }

◆ getAuthId()

ilSimpleSAMLphpWrapper::getAuthId ( )

Returns
string

Implements ilSamlAuth.

Definition at line 72 of file class.ilSimpleSAMLphpWrapper.php.

72 : string
73 {
74 return $this->authSource->getAuthSource()->getAuthId();
75 }

◆ getIdpDiscovery()

ilSimpleSAMLphpWrapper::getIdpDiscovery ( )

Returns
ilSamlIdpDiscovery

Implements ilSamlAuth.

Definition at line 154 of file class.ilSimpleSAMLphpWrapper.php.

155 {
156 return new ilSimpleSAMLphplIdpDiscovery();
157 }
Class ilSimpleSAMLphplIdpDiscovery.

◆ getParam()

ilSimpleSAMLphpWrapper::getParam ( string  $key)

Parameters
string$key
Returns
mixed

Implements ilSamlAuth.

Definition at line 97 of file class.ilSimpleSAMLphpWrapper.php.

98 {
99 $session = SimpleSAML\Session::getSessionFromRequest();
100
101 return $session->getData('ilias', $key);
102 }
string $key
Consumer key/client ID value.
Definition: System.php:193
$session

References ILIAS\LTI\ToolProvider\$key, and $session.

Referenced by popParam().

+ Here is the caller graph for this function:

◆ initConfigFiles()

ilSimpleSAMLphpWrapper::initConfigFiles ( string  $configurationPath)
protected

Definition at line 50 of file class.ilSimpleSAMLphpWrapper.php.

50 : void
51 {
52 global $DIC;
53
54 $templateHandler = new ilSimpleSAMLphpConfigTemplateHandler($DIC->filesystem()->storage());
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 {
58 return substr(str_replace('+', '.', base64_encode(ilPasswordUtils::getBytes(20))), 0, 10);
59 },
60 'COOKIE_PATH' => IL_COOKIE_PATH,
61 'LOG_DIRECTORY' => ilLoggingDBSettings::getInstance()->getLogDir()
62 ]);
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'
66 ]);
67 }
static getBytes(int $length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
global $DIC
Definition: feed.php:28
const IL_COOKIE_PATH(isset($_GET["client_id"]))
Definition: metadata.php:64

References $DIC, ilPasswordUtils\getBytes(), ilLoggingDBSettings\getInstance(), and IL_COOKIE_PATH.

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAuthenticated()

ilSimpleSAMLphpWrapper::isAuthenticated ( )

Returns
bool

Implements ilSamlAuth.

Definition at line 119 of file class.ilSimpleSAMLphpWrapper.php.

119 : bool
120 {
121 return $this->authSource->isAuthenticated();
122 }

◆ logout()

ilSimpleSAMLphpWrapper::logout ( string  $returnUrl = '')

Parameters
string$returnUrl

Implements ilSamlAuth.

Definition at line 135 of file class.ilSimpleSAMLphpWrapper.php.

135 : void
136 {
137 ilSession::set('used_external_auth', false);
138
139 $params = [
140 'ReturnStateParam' => 'LogoutState',
141 'ReturnStateStage' => 'ilLogoutState'
142 ];
143
144 if ($returnUrl !== '') {
145 $params['ReturnTo'] = $returnUrl;
146 }
147
148 $this->authSource->logout($params);
149 }
static set(string $a_var, $a_val)
Set a value.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33

References $params, and ilSession\set().

+ Here is the call graph for this function:

◆ popParam()

ilSimpleSAMLphpWrapper::popParam ( string  $key)

Parameters
string$key
Returns
mixed

Implements ilSamlAuth.

Definition at line 107 of file class.ilSimpleSAMLphpWrapper.php.

108 {
109 $session = SimpleSAML\Session::getSessionFromRequest();
110 $value = $this->getParam($key);
111 $session->deleteData('ilias', $key);
112
113 return $value;
114 }

References ILIAS\LTI\ToolProvider\$key, $session, and getParam().

+ Here is the call graph for this function:

◆ protectResource()

ilSimpleSAMLphpWrapper::protectResource ( )

Protect a script resource with a SAML auth.

Implements ilSamlAuth.

Definition at line 80 of file class.ilSimpleSAMLphpWrapper.php.

80 : void
81 {
82 $this->authSource->requireAuth();
83 }

◆ storeParam()

ilSimpleSAMLphpWrapper::storeParam ( string  $key,
  $value 
)

Parameters
string$key
mixed$value

Implements ilSamlAuth.

Definition at line 88 of file class.ilSimpleSAMLphpWrapper.php.

88 : void
89 {
90 $session = SimpleSAML\Session::getSessionFromRequest();
91 $session->setData('ilias', $key, $value);
92 }

References ILIAS\LTI\ToolProvider\$key, and $session.

Field Documentation

◆ $authSource

SimpleSAML Auth Simple ilSimpleSAMLphpWrapper::$authSource
protected

Definition at line 28 of file class.ilSimpleSAMLphpWrapper.php.

◆ $config

SimpleSAML Configuration ilSimpleSAMLphpWrapper::$config
protected

Definition at line 27 of file class.ilSimpleSAMLphpWrapper.php.


The documentation for this class was generated from the following file: