19 declare(strict_types=1);
47 'hide_own_online_status',
56 'interests_help_offered',
57 'interests_help_looking',
58 'bs_allow_to_contact_me',
59 'chat_osc_accept_msg',
60 'chat_broadcast_typing',
98 $this->storage =
new ilSetting(self::STORAGE_ID);
100 $this->
lng = $DIC->language();
107 if (self::$instance ===
null) {
108 self::$instance =
new self();
111 return self::$instance;
126 $this->provider =
$url;
156 $this->login_element_type = $type;
166 $this->login_element_img_name = $a_img_name;
176 $this->login_element_text = $text;
186 $this->login_prompt_type = $a_type;
196 $this->logout_scope = $a_scope;
206 $this->custom_session = $a_stat;
216 $this->session_duration = $a_duration;
231 $this->allow_sync = $a_stat;
276 array_unshift(
$scopes, self::DEFAULT_SCOPE);
283 if ($this->
filesystem->has(self::FILE_STORAGE .
'/' . $this->getLoginElementImage())) {
311 $this->role_mappings = $a_role_mappings;
324 if (isset($this->role_mappings[$a_role_id][
'value'])) {
325 return (
string) $this->role_mappings[$a_role_id][
'value'];
333 if (isset($this->role_mappings[$a_role_id][
'update'])) {
334 return (
bool) $this->role_mappings[$a_role_id][
'update'];
344 public function validateScopes(
string $discoveryURL, array $custom_scopes): array
351 $curl->setOpt(CURLOPT_HEADER, 0);
352 $curl->setOpt(CURLOPT_RETURNTRANSFER,
true);
353 $curl->setOpt(CURLOPT_TIMEOUT, 4);
357 if ($curl->getInfo(CURLINFO_RESPONSE_CODE) === 200) {
358 $decoded_response = json_decode(
$response,
false, 512, JSON_THROW_ON_ERROR);
359 $available_scopes = $decoded_response->scopes_supported;
360 array_unshift($custom_scopes, self::DEFAULT_SCOPE);
361 if (!empty(array_diff($custom_scopes, $available_scopes))) {
363 self::VALIDATION_ISSUE_INVALID_SCOPE,
364 array_diff($custom_scopes, $available_scopes)
369 self::VALIDATION_ISSUE_DISCOVERY_ERROR,
388 $curl->setOpt(CURLOPT_HEADER, 0);
389 $curl->setOpt(CURLOPT_RETURNTRANSFER,
true);
390 $curl->setOpt(CURLOPT_TIMEOUT, 4);
394 if ($curl->getInfo(CURLINFO_RESPONSE_CODE) === 200) {
395 $decoded_response = json_decode(
$response,
false, 512, JSON_THROW_ON_ERROR);
397 if (isset($decoded_response->scopes_supported) &&
398 is_array($decoded_response->scopes_supported) &&
399 $decoded_response->scopes_supported !== []) {
400 $available_scopes = $decoded_response->scopes_supported;
417 $this->storage->set(
'active', (
string) ((
int) $this->
getActive()));
418 $this->storage->set(
'provider', $this->
getProvider());
419 $this->storage->set(
'client_id', $this->
getClientId());
420 $this->storage->set(
'secret', $this->
getSecret());
426 $this->storage->set(
'logout_scope', (
string) $this->
getLogoutScope());
427 $this->storage->set(
'custom_session', (
string) ((
int) $this->
isCustomSession()));
429 $this->storage->set(
'allow_sync', (
string) ((
int) $this->
isSyncAllowed()));
430 $this->storage->set(
'role', (
string) $this->
getRole());
438 foreach ($this->udf->getDefinitions() as $definition) {
439 $field =
'udf_' . $definition[
'field_id'];
443 $this->storage->set(
'role_mappings', serialize($this->
getRoleMappings()));
448 $this->storage->delete(
'custom_discovery_url');
452 protected function load(): void
455 $this->profile_map[$field] = (string) $this->storage->get(
'pmap_' . $field,
'');
456 $this->profile_update_map[$field] = (bool) $this->storage->get(
'pumap_' . $field,
'0');
458 foreach ($this->udf->getDefinitions() as $definition) {
459 $field =
'udf_' . $definition[
'field_id'];
460 $this->profile_map[$field] = (string) $this->storage->get(
'pmap_' . $field,
'');
461 $this->profile_update_map[$field] = (bool) $this->storage->get(
'pumap_' . $field,
'0');
464 $this->
setActive((
bool) $this->storage->get(
'active',
'0'));
465 $this->
setProvider($this->storage->get(
'provider',
''));
466 $this->
setClientId($this->storage->get(
'client_id',
''));
467 $this->
setSecret($this->storage->get(
'secret',
''));
470 $this->storage->get(
'scopes', serialize([])),
471 [
'allowed_classes' =>
false]
477 $this->
setLoginPromptType((
int) $this->storage->get(
'prompt_type', (
string) self::LOGIN_ENFORCE));
478 $this->
setLogoutScope((
int) $this->storage->get(
'logout_scope', (
string) self::LOGOUT_SCOPE_GLOBAL));
481 $this->
allowSync((
bool) $this->storage->get(
'allow_sync',
'0'));
482 $this->
setRole((
int) $this->storage->get(
'role',
'0'));
483 $this->
setUidField((
string) $this->storage->get(
'uid',
''));
486 $this->storage->get(
'role_mappings', serialize([])),
487 [
'allowed_classes' =>
false]
490 $this->
setValidateScopes((
int) $this->storage->get(
'validate_scopes', (
string) self::URL_VALIDATION_PROVIDER));
498 return (
string) ($this->profile_map[$field] ??
'');
503 $this->profile_map = [];
504 $this->profile_update_map = [];
509 $this->profile_map[$field] = $value;
514 return (
bool) ($this->profile_update_map[$field] ??
false);
519 $this->profile_update_map[$field] = $value;
524 $this->validate_scopes = $validation_mode;
534 $this->custom_discovery_url = $discoveryUrl;
547 $mapping_fields = [];
550 foreach ($usr_profile->getStandardFields() as
$id => $definition) {
551 if (in_array($id, self::IGNORED_USER_FIELDS,
true)) {
554 $mapping_fields[
$id] = $this->
lng->txt($id);
557 return $mapping_fields;
static getWebspaceDir(string $mode="filesystem")
get webspace directory
const URL_VALIDATION_NONE
string $login_element_text
const LOGOUT_SCOPE_GLOBAL
getSupportedScopesFromUrl(string $discoveryURL)
setLoginElementText(string $text)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getProfileMappingFieldValue(string $field)
Additional user data fields definition.
const URL_VALIDATION_PROVIDER
setProfileMappingFieldValue(string $field, string $value)
const IGNORED_USER_FIELDS
getProfileMappingFields()
const LOGIN_ELEMENT_TYPE_TXT
setLoginPromptType(int $a_type)
setClientId(string $client_id)
setCustomDiscoveryUrl(?string $discoveryUrl)
setRoleMappings(array $a_role_mappings)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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)
readonly Filesystem $filesystem
setSecret(string $secret)
getProfileMappingFieldUpdate(string $field)
setUidField(string $field)
getRoleMappingValueForId(int $a_role_id)
validateScopes(string $discoveryURL, array $custom_scopes)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
string $custom_discovery_url
readonly ilSetting $storage
const URL_VALIDATION_CUSTOM
const LOGIN_ELEMENT_TYPE_IMG
setLogoutScope(int $a_scope)
setAdditionalScopes(array $additional_scopes)
setValidateScopes(int $validation_mode)