154 $this->storage =
new ilSetting(self::STORAGE_ID);
155 $this->filesystem = $DIC->filesystem()->web();
165 if (!self::$instance) {
166 self::$instance =
new self();
168 return new self::$instance;
192 $this->provider =
$url;
240 $this->login_element_type =
$type;
256 $this->login_element_img_name = $a_img_name;
269 $this->login_element_text = $text;
283 $this->login_prompt_type = $a_type;
299 $this->logout_scope = $a_scope;
315 $this->custom_session = $a_stat;
331 $this->session_duration = $a_duration;
355 $this->allow_sync = $a_stat;
412 array_unshift($scopes, self::DEFAULT_SCOPE);
425 if ($this->filesystem->has(self::FILE_STORAGE .
'/' . $this->getLoginElementImage())) {
459 $this->role_mappings = $a_role_mappings;
477 isset($this->role_mappings[$a_role_id]) &&
478 isset($this->role_mappings[$a_role_id][
'value'])
480 return (
string) $this->role_mappings[$a_role_id][
'value'];
492 isset($this->role_mappings[$a_role_id]) &&
493 isset($this->role_mappings[$a_role_id][
'update'])
495 return (
bool) $this->role_mappings[$a_role_id][
'update'];
501 $this->validate_scopes = $validation_mode;
511 $this->custom_discovery_url = $discoveryUrl;
526 $curl->setOpt(CURLOPT_HEADER, 0);
527 $curl->setOpt(CURLOPT_RETURNTRANSFER,
true);
528 $curl->setOpt(CURLOPT_TIMEOUT, 4);
532 if ($curl->getInfo(CURLINFO_RESPONSE_CODE) === 200) {
533 $available_scopes =
$response->scopes_supported;
534 $decoded_response = json_decode(
$response,
false, 512, JSON_THROW_ON_ERROR);
535 $available_scopes = $decoded_response->scopes_supported;
536 array_unshift($custom_scopes, self::DEFAULT_SCOPE);
538 $result = array_diff($custom_scopes, $available_scopes);
539 if (!empty(array_diff($custom_scopes, $available_scopes))) {
540 $result = [self::VALIDATION_ISSUE_INVALID_SCOPE, array_diff($custom_scopes, $available_scopes)];
558 $this->storage->set(
'active', (
int) $this->
getActive());
559 $this->storage->set(
'provider', $this->
getProvider());
560 $this->storage->set(
'client_id', $this->
getClientId());
561 $this->storage->set(
'secret', $this->
getSecret());
570 $this->storage->set(
'allow_sync', (
int) $this->
isSyncAllowed());
571 $this->storage->set(
'role', (
int) $this->
getRole());
572 $this->storage->set(
'uid', (
string) $this->
getUidField());
578 $this->storage->set(
'role_mappings', (
string) serialize($this->
getRoleMappings()));
584 $this->storage->delete(
'custom_discovery_url');
594 $this->profile_map[$field] = (string) $this->storage->get(
'pmap_' . $field,
'');
595 $this->profile_update_map[$field] = (bool) $this->storage->get(
'pumap_' . $field,
'');
598 $this->
setActive((
bool) $this->storage->get(
'active', 0));
599 $this->
setProvider($this->storage->get(
'provider',
''));
600 $this->
setClientId($this->storage->get(
'client_id',
''));
601 $this->
setSecret($this->storage->get(
'secret',
''));
602 $this->
setAdditionalScopes((array) unserialize($this->storage->get(
'scopes', serialize([]))));
606 $this->
setLoginPromptType((
int) $this->storage->get(
'prompt_type', self::LOGIN_ENFORCE));
607 $this->
setLogoutScope((
int) $this->storage->get(
'logout_scope', self::LOGOUT_SCOPE_GLOBAL));
608 $this->
useCustomSession((
bool) $this->storage->get(
'custom_session'),
false);
610 $this->
allowSync((
bool) $this->storage->get(
'allow_sync'),
false);
611 $this->
setRole((
int) $this->storage->get(
'role'), 0);
612 $this->
setUidField((
string) $this->storage->get(
'uid'),
'');
613 $this->
setRoleMappings((array) unserialize($this->storage->get(
'role_mappings', serialize([]))));
614 $this->
setValidateScopes((
int) $this->storage->get(
'validate_scopes', (
string) self::URL_VALIDATION_PROVIDER));
625 return (
string) $this->profile_map[$field];
634 $this->profile_map[$field] = $value;
643 return (
bool) $this->profile_update_map[$field];
652 $this->profile_update_map[$field] = $value;
662 'firstname' =>
'firstname',
663 'lastname' =>
'lastname',
665 'birthday' =>
'birthday' const URL_VALIDATION_NONE
const LOGOUT_SCOPE_GLOBAL
setLoginElementText(string $text)
getProfileMappingFieldValue(string $field)
getRoleMappingValueForId($a_role_id)
const URL_VALIDATION_PROVIDER
deleteImageFile()
Delete image file.
setProfileMappingFieldValue(string $field, string $value)
getProfileMappingFields()
const LOGIN_ELEMENT_TYPE_TXT
setLoginPromptType(int $a_type)
static getInstance()
Get singleton instance.
setClientId(string $client_id)
setCustomDiscoveryUrl(?string $discoveryUrl)
setRoleMappings(array $a_role_mappings)
setLoginElementType(int $type)
Set login element type.
useCustomSession(bool $a_stat)
const VALIDATION_ISSUE_DISCOVERY_ERROR
const VALIDATION_ISSUE_INVALID_SCOPE
Class ilOpenIdConnectSettingsGUI.
setSessionDuration(int $a_duration)
__construct()
ilOpenIdConnectSettings constructor.
setProfileMappingFieldUpdate(string $field, bool $value)
setLoginElementImage(string $a_img_name)
load()
Load from settings.
setSecret(string $secret)
getProfileMappingFieldUpdate(string $field)
getRoleMappingUpdateForId($a_role_id)
setUidField(string $field)
validateScopes(string $discoveryURL, array $custom_scopes)
const URL_VALIDATION_CUSTOM
const LOGIN_ELEMENT_TYPE_IMG
getRoleMappings()
Get role mappings.
setLogoutScope(int $a_scope)
static getWebspaceDir($mode="filesystem")
get webspace directory
setAdditionalScopes(array $additional_scopes)
setValidateScopes(int $validation_mode)