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 ()
 

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.

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

29  {
30  $this->initConfigFiles($configurationPath);
31 
32  SimpleSAML_Configuration::setConfigDir($configurationPath);
33  $this->config = SimpleSAML_Configuration::getInstance();
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 setConfigDir($path, $configSet='simplesaml')
Set the directory for configuration files for the given configuration set.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
+ 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 ( )

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.

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

Referenced by popParam().

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

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

Referenced by __construct().

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  }
global $DIC
Definition: saml.php:7
static getBytes($length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
copy($sourcePath, $destinationPath, array $placeholders=[])
const IL_COOKIE_PATH(isset($_GET["client_id"]))
Definition: metadata.php:32
static getInstance()
Get instance.
Class ilSimpleSAMLphpConfigTemplateHandler.
+ 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.

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

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.
+ 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.

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

112  {
114  $value = $this->getParam($key);
115  $session->deleteData('ilias', $key);
116 
117  return $value;
118  }
$session
$key
Definition: croninfo.php:18
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:241
+ 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.

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

91  {
93  $session->setData('ilias', $key, $value);
94  }
$session
$key
Definition: croninfo.php:18
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:241
+ 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: