ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSimpleSAMLphpWrapper Class Reference
+ 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, mixed $value)
 
 getParam (string $key)
 
 popParam (string $key)
 
 isAuthenticated ()
 
 getAttributes ()
 
 logout (string $returnUrl='')
 
 getIdpDiscovery ()
 
 getAuthDataArray ()
 
 getAuthId ()
 
 protectResource ()
 Protect a script resource with a SAML auth. More...
 
 storeParam (string $key, mixed $value)
 
 isAuthenticated ()
 
 popParam (string $key)
 
 getParam (string $key)
 
 getAttributes ()
 
 logout (string $returnUrl='')
 
 getIdpDiscovery ()
 
 getAuthDataArray ()
 

Private Member Functions

 initConfigFiles (string $configurationPath)
 

Private Attributes

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

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

29 {
30 $this->initConfigFiles($configurationPath);
31
32 SimpleSAML\Configuration::setConfigDir($configurationPath);
33 $this->config = SimpleSAML\Configuration::getInstance();
34
35 $storageType = $this->config->getString('store.type');
36
37 if (in_array($storageType, ['phpsession', ''], true)) {
38 throw new RuntimeException('Invalid SimpleSAMLphp session handler: Must not be phpsession or empty');
39 }
40
41 $this->authSource = new SimpleSAML\Auth\Simple($authSourceName);
42 }
initConfigFiles(string $configurationPath)

References initConfigFiles().

+ Here is the call graph for this function:

Member Function Documentation

◆ getAttributes()

ilSimpleSAMLphpWrapper::getAttributes ( )

Implements ilSamlAuth.

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

100 : array
101 {
102 return $this->authSource->getAttributes();
103 }

◆ getAuthDataArray()

ilSimpleSAMLphpWrapper::getAuthDataArray ( )

Implements ilSamlAuth.

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

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

◆ getAuthId()

ilSimpleSAMLphpWrapper::getAuthId ( )

Implements ilSamlAuth.

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

63 : string
64 {
65 return $this->authSource->getAuthSource()->getAuthId();
66 }

◆ getIdpDiscovery()

ilSimpleSAMLphpWrapper::getIdpDiscovery ( )

◆ getParam()

ilSimpleSAMLphpWrapper::getParam ( string  $key)
Returns
mixed

Implements ilSamlAuth.

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

80 {
81 $session = SimpleSAML\Session::getSessionFromRequest();
82
83 return $session->getData(self::ILIAS, $key);
84 }

Referenced by popParam().

+ Here is the caller graph for this function:

◆ initConfigFiles()

ilSimpleSAMLphpWrapper::initConfigFiles ( string  $configurationPath)
private

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

44 : void
45 {
46 global $DIC;
47
48 $templateHandler = new ilSimpleSAMLphpConfigTemplateHandler($DIC->filesystem()->storage());
49 $templateHandler->copy('../components/ILIAS/Saml/resources/config.php.dist', 'auth/saml/config/config.php', [
50 'DB_PATH' => rtrim($configurationPath, '/') . '/ssphp.sq3',
51 'SQL_INITIAL_PASSWORD' => static function (): string {
52 return substr(str_replace('+', '.', base64_encode(ilPasswordUtils::getBytes(20))), 0, 10);
53 },
54 'COOKIE_PATH' => IL_COOKIE_PATH,
55 'LOG_DIRECTORY' => ilLoggingDBSettings::getInstance()->getLogDir()
56 ]);
57 $templateHandler->copy('../components/ILIAS/Saml/resources/authsources.php.dist', 'auth/saml/config/authsources.php', [
58 'RELAY_STATE' => rtrim(ILIAS_HTTP_PATH, '/') . '/saml.php',
59 'SP_ENTITY_ID' => rtrim(ILIAS_HTTP_PATH, '/') . '/metadata.php'
60 ]);
61 }
const IL_COOKIE_PATH(isset($_GET['client_id']))
Definition: index.php:47
static getBytes(int $length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
global $DIC
Definition: shib_login.php:26

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

Implements ilSamlAuth.

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

95 : bool
96 {
97 return $this->authSource->isAuthenticated();
98 }

◆ logout()

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

Implements ilSamlAuth.

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

105 : void
106 {
107 ilSession::clear('used_external_auth_mode');
108
109 $params = [
110 'ReturnStateParam' => 'LogoutState',
111 'ReturnStateStage' => 'ilLogoutState'
112 ];
113
114 if ($returnUrl !== '') {
115 $params['ReturnTo'] = $returnUrl;
116 }
117
118 $this->authSource->logout($params);
119 }
static clear(string $a_var)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31

References $params, and ilSession\clear().

+ Here is the call graph for this function:

◆ popParam()

ilSimpleSAMLphpWrapper::popParam ( string  $key)
Returns
mixed

Implements ilSamlAuth.

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

87 {
88 $session = SimpleSAML\Session::getSessionFromRequest();
89 $value = $this->getParam($key);
90 $session->deleteData(self::ILIAS, $key);
91
92 return $value;
93 }

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

68 : void
69 {
70 $this->authSource->requireAuth();
71 }

◆ storeParam()

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

Implements ilSamlAuth.

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

73 : void
74 {
75 $session = SimpleSAML\Session::getSessionFromRequest();
76 $session->setData(self::ILIAS, $key, $value);
77 }

Field Documentation

◆ $authSource

SimpleSAML Auth Simple ilSimpleSAMLphpWrapper::$authSource
private

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

◆ $config

SimpleSAML Configuration ilSimpleSAMLphpWrapper::$config
private

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

◆ ILIAS

const string ilSimpleSAMLphpWrapper::ILIAS = 'ilias'
private

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


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