ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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
string
More...
 
 protectResource ()
 Protect a script resource with a SAML auth. More...
 
 storeParam ($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 ()
 

Protected Member Functions

 initConfigFiles ($configurationPath)
 

Protected Attributes

 $config
 
 $authSource
 

Detailed Description

Class ilSimpleSAMLphpWrapper.

Definition at line 7 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 25 of file class.ilSimpleSAMLphpWrapper.php.

References initConfigFiles().

26  {
27  $this->initConfigFiles($configurationPath);
28 
29  SimpleSAML\Configuration::setConfigDir($configurationPath);
30  $this->config = SimpleSAML\Configuration::getInstance();
31 
32  $sessionHandler = $this->config->getString('session.handler', false);
33  $storageType = $this->config->getString('store.type', false);
34 
35  if (
36  $storageType == 'phpsession' || $sessionHandler == 'phpsession' ||
37  (empty($storageType) && empty($sessionHandler))
38  ) {
39  throw new RuntimeException('Invalid SimpleSAMLphp session handler: Must not be phpsession');
40  }
41 
42  $this->authSource = new SimpleSAML\Auth\Simple($authSourceName);
43  }
+ 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 ( )

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

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

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

References $session.

Referenced by popParam().

96  {
97  $session = SimpleSAML\Session::getSessionFromRequest();
98 
99  $value = $session->getData('ilias', $key);
100 
101  return $value;
102  }
$session
+ Here is the caller graph for this function:

◆ initConfigFiles()

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

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

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

Referenced by __construct().

49  {
50  global $DIC;
51 
52  $templateHandler = new ilSimpleSAMLphpConfigTemplateHandler($DIC->filesystem()->storage());
53  $templateHandler->copy('./Services/Saml/lib/config.php.dist', 'auth/saml/config/config.php', [
54  'DB_PATH' => rtrim($configurationPath, '/') . '/ssphp.sq3',
55  'SQL_INITIAL_PASSWORD' => function () {
56  return substr(str_replace('+', '.', base64_encode(ilPasswordUtils::getBytes(20))), 0, 10);
57  },
58  'COOKIE_PATH' => IL_COOKIE_PATH,
59  'LOG_DIRECTORY' => ilLoggingDBSettings::getInstance()->getLogDir()
60  ]);
61  $templateHandler->copy('./Services/Saml/lib/authsources.php.dist', 'auth/saml/config/authsources.php', [
62  'RELAY_STATE' => rtrim(ILIAS_HTTP_PATH, '/') . '/saml.php',
63  'SP_ENTITY_ID' => rtrim(ILIAS_HTTP_PATH, '/') . '/Services/Saml/lib/metadata.php'
64  ]);
65  }
copy(string $sourcePath, string $destinationPath, array $placeholders=[])
static getBytes($length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
global $DIC
Definition: goto.php:24
static getInstance()
Get instance.
Class ilSimpleSAMLphpConfigTemplateHandler.
const IL_COOKIE_PATH(isset($_GET["client_id"]))
Definition: metadata.php:47
+ 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.

References ilSession\set().

135  : void
136  {
137  ilSession::set('used_external_auth', false);
138 
139  $params = [
140  'ReturnStateParam' => 'LogoutState',
141  'ReturnStateStage' => 'ilLogoutState'
142  ];
143 
144  if (strlen($returnUrl) > 0) {
145  $params['ReturnTo'] = $returnUrl;
146  }
147 
148  $this->authSource->logout($params);
149  }
static set($a_var, $a_val)
Set a value.
+ 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.

References $session, and getParam().

108  {
109  $session = SimpleSAML\Session::getSessionFromRequest();
110  $value = $this->getParam($key);
111  $session->deleteData('ilias', $key);
112 
113  return $value;
114  }
$session
+ Here is the call graph for this function:

◆ protectResource()

ilSimpleSAMLphpWrapper::protectResource ( )

Protect a script resource with a SAML auth.

Implements ilSamlAuth.

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

78  : void
79  {
80  $this->authSource->requireAuth();
81  }

◆ storeParam()

ilSimpleSAMLphpWrapper::storeParam (   $key,
  $value 
)

Parameters
string$key
mixed$value

Implements ilSamlAuth.

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

References $session.

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

Field Documentation

◆ $authSource

ilSimpleSAMLphpWrapper::$authSource
protected

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

◆ $config

ilSimpleSAMLphpWrapper::$config
protected

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


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