ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSimpleSAMLphpWrapper Class Reference

Class ilSimpleSAMLphpWrapper. More...

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

Public Member Functions

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

Protected Member Functions

 initConfigFiles ($configurationPath)
 

Protected Attributes

 $config
 
 $authSource
 

Detailed Description

Class ilSimpleSAMLphpWrapper.

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

Constructor & Destructor Documentation

◆ __construct()

ilSimpleSAMLphpWrapper::__construct (   $authSourceName,
  $configurationPath 
)

ilSimpleSAMLphpWrapper constructor.

Parameters
string$authSourceName
string$configurationPath
Exceptions
Exception

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

29 {
30 $this->initConfigFiles($configurationPath);
31
34
35 $sessionHandler = $this->config->getString('session.handler', false);
36 $storageType = $this->config->getString('store.type', false);
37
38 if (
39 $storageType == 'phpsession' || $sessionHandler == 'phpsession' ||
40 (empty($storageType) && empty($sessionHandler))
41 ) {
42 throw new RuntimeException('Invalid SimpleSAMLphp session handler: Must not be phpsession');
43 }
44
45 $this->authSource = new SimpleSAML\Auth\Simple($authSourceName);
46 }
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static setConfigDir($path, $configSet='simplesaml')
Set the directory for configuration files for the given configuration set.

References SimpleSAML_Configuration\getInstance(), initConfigFiles(), and SimpleSAML_Configuration\setConfigDir().

+ Here is the call graph for this function:

Member Function Documentation

◆ getAttributes()

ilSimpleSAMLphpWrapper::getAttributes ( )

Returns
array

Implements ilSamlAuth.

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

132 {
133 return $this->authSource->getAttributes();
134 }

◆ getAuthDataArray()

ilSimpleSAMLphpWrapper::getAuthDataArray ( )

@inheritDoc

Implements ilSamlAuth.

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

167 {
168 return $this->authSource->getAuthDataArray();
169 }

◆ getAuthId()

ilSimpleSAMLphpWrapper::getAuthId ( )

Returns
mixed

Implements ilSamlAuth.

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

75 {
76 return $this->authSource->getAuthSource()->getAuthId();
77 }

◆ getIdpDiscovery()

ilSimpleSAMLphpWrapper::getIdpDiscovery ( )

Returns
ilSamlIdpDiscovery

Implements ilSamlAuth.

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

159 {
160 return new ilSimpleSAMLphplIdpDiscovery();
161 }
Class ilSimpleSAMLphplIdpDiscovery.

◆ getParam()

ilSimpleSAMLphpWrapper::getParam (   $key)

Parameters
string$key
Returns
mixed

Implements ilSamlAuth.

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

100 {
102
103 $value = $session->getData('ilias', $key);
104
105 return $value;
106 }
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:241
$key
Definition: croninfo.php:18
$session

References $key, $session, and SimpleSAML_Session\getSessionFromRequest().

Referenced by popParam().

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

◆ initConfigFiles()

ilSimpleSAMLphpWrapper::initConfigFiles (   $configurationPath)
protected
Parameters
string$configurationPath

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

52 {
53 global $DIC;
54
55 $templateHandler = new ilSimpleSAMLphpConfigTemplateHandler($DIC->filesystem()->storage());
56 $templateHandler->copy('./Services/Saml/lib/config.php.dist', 'auth/saml/config/config.php', [
57 'DB_PATH' => rtrim($configurationPath, '/') . '/ssphp.sq3',
58 'SQL_INITIAL_PASSWORD' => function () {
59 require_once 'Services/Password/classes/class.ilPasswordUtils.php';
60 return substr(str_replace('+', '.', base64_encode(ilPasswordUtils::getBytes(20))), 0, 10);
61 },
62 'COOKIE_PATH' => IL_COOKIE_PATH,
63 'LOG_DIRECTORY' => ilLoggingDBSettings::getInstance()->getLogDir()
64 ]);
65 $templateHandler->copy('./Services/Saml/lib/authsources.php.dist', 'auth/saml/config/authsources.php', [
66 'RELAY_STATE' => rtrim(ILIAS_HTTP_PATH, '/') . '/saml.php',
67 'SP_ENTITY_ID' => rtrim(ILIAS_HTTP_PATH, '/') . '/Services/Saml/lib/metadata.php'
68 ]);
69 }
const IL_COOKIE_PATH(isset($_GET["client_id"]))
Definition: metadata.php:32
static getInstance()
Get instance.
static getBytes($length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
global $DIC
Definition: saml.php:7

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 123 of file class.ilSimpleSAMLphpWrapper.php.

124 {
125 return $this->authSource->isAuthenticated();
126 }

◆ logout()

ilSimpleSAMLphpWrapper::logout (   $returnUrl = '')

Parameters
string$returnUrl

Implements ilSamlAuth.

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

140 {
141 ilSession::set('used_external_auth', false);
142
143 $params = array(
144 'ReturnStateParam' => 'LogoutState',
145 'ReturnStateStage' => 'ilLogoutState'
146 );
147
148 if (strlen($returnUrl) > 0) {
149 $params['ReturnTo'] = $returnUrl;
150 }
151
152 $this->authSource->logout($params);
153 }
static set($a_var, $a_val)
Set a value.

References PHPMailer\PHPMailer\$params, and ilSession\set().

+ Here is the call graph for this function:

◆ popParam()

ilSimpleSAMLphpWrapper::popParam (   $key)

Parameters
string$key
Returns
mixed

Implements ilSamlAuth.

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

112 {
114 $value = $this->getParam($key);
115 $session->deleteData('ilias', $key);
116
117 return $value;
118 }

References $key, $session, getParam(), and SimpleSAML_Session\getSessionFromRequest().

+ Here is the call graph for this function:

◆ protectResource()

ilSimpleSAMLphpWrapper::protectResource ( )

Protect a script resource with a SAML auth.

Implements ilSamlAuth.

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

83 {
84 $this->authSource->requireAuth();
85 }

◆ storeParam()

ilSimpleSAMLphpWrapper::storeParam (   $key,
  $value 
)

Parameters
string$key
mixed$value

Implements ilSamlAuth.

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

91 {
93 $session->setData('ilias', $key, $value);
94 }

References $key, $session, and SimpleSAML_Session\getSessionFromRequest().

+ Here is the call graph for this function:

Field Documentation

◆ $authSource

ilSimpleSAMLphpWrapper::$authSource
protected

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

◆ $config

ilSimpleSAMLphpWrapper::$config
protected

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


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