3 declare(strict_types=1);
80 $this->storage =
new ilSetting(self::STORAGE_ID);
87 if (self::$instance === null) {
88 self::$instance =
new self();
91 return self::$instance;
106 $this->provider =
$url;
136 $this->login_element_type =
$type;
146 $this->login_element_img_name = $a_img_name;
156 $this->login_element_text = $text;
167 $this->login_prompt_type = $a_type;
177 $this->logout_scope = $a_scope;
187 $this->custom_session = $a_stat;
197 $this->session_duration = $a_duration;
212 $this->allow_sync = $a_stat;
258 array_unshift(
$scopes, self::DEFAULT_SCOPE);
269 if ($this->
filesystem->has(self::FILE_STORAGE .
'/' . $this->getLoginElementImage())) {
297 $this->role_mappings = $a_role_mappings;
310 if (isset($this->role_mappings[$a_role_id][
'value'])) {
311 return (
string) $this->role_mappings[$a_role_id][
'value'];
319 if (isset($this->role_mappings[$a_role_id][
'update'])) {
320 return (
bool) $this->role_mappings[$a_role_id][
'update'];
326 public function validateScopes(
string $discoveryURL, array $custom_scopes): array
333 $curl->setOpt(CURLOPT_HEADER, 0);
334 $curl->setOpt(CURLOPT_RETURNTRANSFER,
true);
335 $curl->setOpt(CURLOPT_TIMEOUT, 4);
339 if ($curl->getInfo(CURLINFO_RESPONSE_CODE) === 200) {
340 $decoded_response = json_decode(
$response,
false, 512, JSON_THROW_ON_ERROR);
341 $available_scopes = $decoded_response->scopes_supported;
342 array_unshift($custom_scopes, self::DEFAULT_SCOPE);
343 if (!empty(array_diff($custom_scopes, $available_scopes))) {
344 $result = [self::VALIDATION_ISSUE_INVALID_SCOPE, array_diff($custom_scopes, $available_scopes)];
347 $result = [self::VALIDATION_ISSUE_DISCOVERY_ERROR,
$response];
359 $this->storage->set(
'active', (
string) ((
int) $this->
getActive()));
360 $this->storage->set(
'provider', $this->
getProvider());
361 $this->storage->set(
'client_id', $this->
getClientId());
362 $this->storage->set(
'secret', $this->
getSecret());
368 $this->storage->set(
'logout_scope', (
string) $this->
getLogoutScope());
369 $this->storage->set(
'custom_session', (
string) ((
int) $this->
isCustomSession()));
371 $this->storage->set(
'allow_sync', (
string) ((
int) $this->
isSyncAllowed()));
372 $this->storage->set(
'role', (
string) $this->
getRole());
379 $this->storage->set(
'role_mappings', serialize($this->
getRoleMappings()));
384 $this->storage->delete(
'custom_discovery_url');
388 protected function load(): void
391 $this->profile_map[$field] = (string) $this->storage->get(
'pmap_' . $field,
'');
392 $this->profile_update_map[$field] = (bool) $this->storage->get(
'pumap_' . $field,
'0');
395 $this->
setActive((
bool) $this->storage->get(
'active',
'0'));
396 $this->
setProvider($this->storage->get(
'provider',
''));
397 $this->
setClientId($this->storage->get(
'client_id',
''));
398 $this->
setSecret($this->storage->get(
'secret',
''));
400 $this->storage->get(
'scopes', serialize([])),
401 [
'allowed_classes' =>
false]
406 $this->
setLoginPromptType((
int) $this->storage->get(
'prompt_type', (
string) self::LOGIN_ENFORCE));
407 $this->
setLogoutScope((
int) $this->storage->get(
'logout_scope', (
string) self::LOGOUT_SCOPE_GLOBAL));
410 $this->
allowSync((
bool) $this->storage->get(
'allow_sync',
'0'));
411 $this->
setRole((
int) $this->storage->get(
'role',
'0'));
412 $this->
setUidField((
string) $this->storage->get(
'uid',
''));
414 $this->storage->get(
'role_mappings', serialize([])),
415 [
'allowed_classes' =>
false]
417 $this->
setValidateScopes((
int) $this->storage->get(
'validate_scopes', (
string) self::URL_VALIDATION_PROVIDER));
425 return (
string) ($this->profile_map[$field] ??
'');
430 $this->profile_map[$field] = $value;
435 return (
bool) ($this->profile_update_map[$field] ??
false);
440 $this->profile_update_map[$field] = $value;
445 $this->validate_scopes = $validation_mode;
455 $this->custom_discovery_url = $discoveryUrl;
468 'firstname' =>
'firstname',
469 'lastname' =>
'lastname',
471 'birthday' =>
'birthday' static getWebspaceDir(string $mode="filesystem")
get webspace directory
const URL_VALIDATION_NONE
string $login_element_text
const LOGOUT_SCOPE_GLOBAL
setLoginElementText(string $text)
getProfileMappingFieldValue(string $field)
const URL_VALIDATION_PROVIDER
setProfileMappingFieldValue(string $field, string $value)
getProfileMappingFields()
const LOGIN_ELEMENT_TYPE_TXT
setLoginPromptType(int $a_type)
setClientId(string $client_id)
setCustomDiscoveryUrl(?string $discoveryUrl)
setRoleMappings(array $a_role_mappings)
setLoginElementType(int $type)
getRoleMappingUpdateForId(int $a_role_id)
string $login_element_img_name
useCustomSession(bool $a_stat)
const VALIDATION_ISSUE_DISCOVERY_ERROR
array $profile_update_map
const VALIDATION_ISSUE_INVALID_SCOPE
setSessionDuration(int $a_duration)
setProfileMappingFieldUpdate(string $field, bool $value)
setLoginElementImage(string $a_img_name)
setSecret(string $secret)
getProfileMappingFieldUpdate(string $field)
setUidField(string $field)
getRoleMappingValueForId(int $a_role_id)
validateScopes(string $discoveryURL, array $custom_scopes)
string $custom_discovery_url
const URL_VALIDATION_CUSTOM
const LOGIN_ELEMENT_TYPE_IMG
setLogoutScope(int $a_scope)
setAdditionalScopes(array $additional_scopes)
Class FlySystemFileAccessTest disabled disabled disabled.
setValidateScopes(int $validation_mode)