ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilSimpleSAMLphpWrapper Class Reference

Class ilSimpleSAMLphpWrapper. More...

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

Public Member Functions

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

Private Member Functions

 initConfigFiles (string $configurationPath)
 

Private Attributes

const ILIAS = 'ilias'
 
readonly SimpleSAML Configuration $config
 
readonly SimpleSAML Auth Simple $authSource
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References initConfigFiles().

33  {
34  $this->initConfigFiles($configurationPath);
35 
36  SimpleSAML\Configuration::setConfigDir($configurationPath);
37  $this->config = SimpleSAML\Configuration::getInstance();
38 
39  $storageType = $this->config->getString('store.type');
40 
41  if (in_array($storageType, ['phpsession', ''], true)) {
42  throw new RuntimeException('Invalid SimpleSAMLphp session handler: Must not be phpsession or empty');
43  }
44 
45  $this->authSource = new SimpleSAML\Auth\Simple($authSourceName);
46  }
initConfigFiles(string $configurationPath)
+ Here is the call graph for this function:

Member Function Documentation

◆ getAttributes()

ilSimpleSAMLphpWrapper::getAttributes ( )

Implements ilSamlAuth.

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

104  : array
105  {
106  return $this->authSource->getAttributes();
107  }

◆ getAuthDataArray()

ilSimpleSAMLphpWrapper::getAuthDataArray ( )

Implements ilSamlAuth.

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

130  : array
131  {
132  return $this->authSource->getAuthDataArray();
133  }

◆ getAuthId()

ilSimpleSAMLphpWrapper::getAuthId ( )

Implements ilSamlAuth.

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

67  : string
68  {
69  return $this->authSource->getAuthSource()->getAuthId();
70  }

◆ getIdpDiscovery()

ilSimpleSAMLphpWrapper::getIdpDiscovery ( )

Implements ilSamlAuth.

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

126  {
127  return new ilSimpleSAMLphplIdpDiscovery();
128  }
Class ilSimpleSAMLphplIdpDiscovery.

◆ getParam()

ilSimpleSAMLphpWrapper::getParam ( string  $key)
Returns
mixed

Implements ilSamlAuth.

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

Referenced by popParam().

84  {
85  $session = SimpleSAML\Session::getSessionFromRequest();
86 
87  return $session->getData(self::ILIAS, $key);
88  }
+ Here is the caller graph for this function:

◆ initConfigFiles()

ilSimpleSAMLphpWrapper::initConfigFiles ( string  $configurationPath)
private

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

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

Referenced by __construct().

48  : void
49  {
50  global $DIC;
51 
52  $templateHandler = new ilSimpleSAMLphpConfigTemplateHandler($DIC->filesystem()->storage());
53  $templateHandler->copy('../components/ILIAS/Saml/resources/config.php.dist', 'auth/saml/config/config.php', [
54  'DB_PATH' => rtrim($configurationPath, '/') . '/ssphp.sq3',
55  'SQL_INITIAL_PASSWORD' => static function (): string {
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('../components/ILIAS/Saml/resources/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, '/') . '/metadata.php'
64  ]);
65  }
copy(string $sourcePath, string $destinationPath, array $placeholders=[])
global $DIC
Definition: shib_login.php:25
static getBytes(int $length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
const IL_COOKIE_PATH(isset($_GET['client_id']))
Definition: index.php:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAuthenticated()

ilSimpleSAMLphpWrapper::isAuthenticated ( )

Implements ilSamlAuth.

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

99  : bool
100  {
101  return $this->authSource->isAuthenticated();
102  }

◆ logout()

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

Implements ilSamlAuth.

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

References $params, and ilSession\clear().

109  : void
110  {
111  ilSession::clear('used_external_auth_mode');
112 
113  $params = [
114  'ReturnStateParam' => 'LogoutState',
115  'ReturnStateStage' => 'ilLogoutState'
116  ];
117 
118  if ($returnUrl !== '') {
119  $params['ReturnTo'] = $returnUrl;
120  }
121 
122  $this->authSource->logout($params);
123  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
static clear(string $a_var)
+ Here is the call graph for this function:

◆ popParam()

ilSimpleSAMLphpWrapper::popParam ( string  $key)
Returns
mixed

Implements ilSamlAuth.

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

References getParam().

91  {
92  $session = SimpleSAML\Session::getSessionFromRequest();
93  $value = $this->getParam($key);
94  $session->deleteData(self::ILIAS, $key);
95 
96  return $value;
97  }
+ Here is the call graph for this function:

◆ protectResource()

ilSimpleSAMLphpWrapper::protectResource ( )

Protect a script resource with a SAML auth.

Implements ilSamlAuth.

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

72  : void
73  {
74  $this->authSource->requireAuth();
75  }

◆ storeParam()

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

Implements ilSamlAuth.

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

77  : void
78  {
79  $session = SimpleSAML\Session::getSessionFromRequest();
80  $session->setData(self::ILIAS, $key, $value);
81  }

Field Documentation

◆ $authSource

readonly SimpleSAML Auth Simple ilSimpleSAMLphpWrapper::$authSource
private

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

◆ $config

readonly SimpleSAML Configuration ilSimpleSAMLphpWrapper::$config
private

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

◆ ILIAS

const ilSimpleSAMLphpWrapper::ILIAS = 'ilias'
private

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


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