19 declare(strict_types=1);
52 $this->ref_id = $a_ref_id;
54 $this->
lng = $DIC->language();
55 $this->
lng->loadLanguageModule(
'auth');
58 $this->
tabs = $DIC->tabs();
59 $this->
ctrl = $DIC->ctrl();
60 $this->
logger = $DIC->logger()->auth();
62 $this->
access = $DIC->access();
63 $this->review = $DIC->rbac()->review();
64 $this->error = $DIC[
'ilErr'];
65 $this->
upload = $DIC->upload();
66 $this->body = $DIC->http()->request()->getParsedBody();
73 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->WARNING);
79 return $this->
access->checkAccess($a_permission,
'', $this->ref_id);
86 switch ($this->
ctrl->getNextClass()) {
88 $cmd = $this->
ctrl->getCmd(self::DEFAULT_CMD);
110 $form->setTitle($this->
lng->txt(
'auth_oidc_settings_title'));
111 $form->setFormAction($this->
ctrl->getFormAction($this));
115 $this->
lng->txt(
'auth_oidc_settings_activation'),
119 $form->addItem($activation);
123 $this->
lng->txt(
'auth_oidc_settings_provider'),
131 $this->
lng->txt(
'auth_oidc_settings_client_id'),
140 $this->
lng->txt(
'auth_oidc_settings_secret'),
143 $secret->setSkipSyntaxCheck(
true);
146 if ($this->
settings->getSecret() !==
'') {
152 $this->
lng->txt(
'auth_oidc_settings_additional_scopes'),
156 $default_scope->setDisabled(
true);
157 $form->addItem($default_scope);
164 $scopeValues = $this->
settings->getAdditionalScopes();
165 if (isset($scopeValues[0])) {
166 $scopes->setValue($scopeValues[0]);
168 $scopes->setMultiValues($scopeValues);
174 $this->
lng->txt(
'auth_oidc_settings_validate_scopes'),
177 $validation_options->
setValue((
string) $this->
settings->getValidateScopes());
178 $form->addItem($validation_options);
181 $this->
lng->txt(
'auth_oidc_settings_validate_scope_default'),
185 $validation_options->addOption($base_valid_url_option);
189 'custom_discovery_url' 193 $this->
lng->txt(
'auth_oidc_settings_validate_scope_custom'),
196 $validation_options->addOption($custom_valid_url_option);
197 $custom_validation_url->setValue($this->
settings->getCustomDiscoveryUrl() ??
'');
198 $custom_validation_url->setMaxLength(120);
199 $custom_validation_url->setInfo($this->
lng->txt(
'auth_oidc_settings_discovery_url'));
200 $custom_valid_url_option->addSubItem($custom_validation_url);
202 $this->
lng->txt(
'auth_oidc_settings_validate_scope_none'),
205 $validation_options->addOption($no_validation_option);
209 $this->
lng->txt(
'auth_oidc_settings_le'),
213 $login_element->setValue((
string) $this->
settings->getLoginElementType());
214 $form->addItem($login_element);
218 $this->
lng->txt(
'auth_oidc_settings_txt'),
221 $login_element->addOption($text_option);
228 $text->setValue($this->
settings->getLoginElemenText());
229 $text->setMaxLength(120);
230 $text->setInfo($this->
lng->txt(
'auth_oidc_settings_txt_val_info'));
231 $text_option->addSubItem($text);
235 $this->
lng->txt(
'auth_oidc_settings_img'),
238 $login_element->addOption($img_option);
244 $image->setAllowDeletion(
false);
246 if ($this->
settings->hasImageFile()) {
247 $image->setImage($this->
settings->getImageFilePath());
249 $image->setInfo($this->
lng->txt(
'auth_oidc_settings_img_file_info'));
250 $img_option->addSubItem($image);
254 $this->
lng->txt(
'auth_oidc_settings_login_options'),
261 $this->
lng->txt(
'auth_oidc_settings_login_option_enforce'),
264 $enforce->setInfo($this->
lng->txt(
'auth_oidc_settings_login_option_enforce_info'));
265 $login_options->addOption($enforce);
269 $this->
lng->txt(
'auth_oidc_settings_login_option_default'),
272 $default->setInfo($this->
lng->txt(
'auth_oidc_settings_login_option_default_info'));
273 $login_options->addOption($default);
275 $form->addItem($login_options);
279 $this->
lng->txt(
'auth_oidc_settings_logout_scope'),
286 $this->
lng->txt(
'auth_oidc_settings_logout_scope_global'),
289 $global_scope->setInfo($this->
lng->txt(
'auth_oidc_settings_logout_scope_global_info'));
290 $logout_scope->addOption($global_scope);
294 $this->
lng->txt(
'auth_oidc_settings_logout_scope_local'),
297 $ilias_scope->setInfo($this->
lng->txt(
'auth_oidc_settings_logout_scope_local_info'));
298 $logout_scope->addOption($ilias_scope);
300 $form->addItem($logout_scope);
303 $this->
lng->txt(
'auth_oidc_settings_custom_session_duration_type'),
307 $this->
lng->txt(
'auth_oidc_settings_custom_session_duration_option')
309 $use_custom_session->setChecked($this->
settings->isCustomSession());
310 $form->addItem($use_custom_session);
314 $this->
lng->txt(
'auth_oidc_settings_session_duration'),
322 $use_custom_session->addSubItem(
$session);
326 $form->addCommandButton(
'saveSettings', $this->
lng->txt(
'save'));
331 $user_sync->setTitle($this->
lng->txt(
'auth_oidc_settings_section_user_sync'));
332 $form->addItem($user_sync);
335 $this->
lng->txt(
'auth_oidc_settings_user_sync'),
339 $sync->setInfo($this->
lng->txt(
'auth_oidc_settings_user_sync_info'));
340 $sync->setValue(
"1");
341 $form->addItem($sync);
344 $this->
lng->txt(
'auth_oidc_settings_default_role'),
347 $roles->setValue($this->
settings->getRole());
348 $roles->setInfo($this->
lng->txt(
'auth_oidc_settings_default_role_info'));
350 $roles->setRequired(
true);
351 $sync->addSubItem($roles);
354 $this->
lng->txt(
'auth_oidc_settings_user_attr'),
357 $user_attr->setValue($this->
settings->getUidField());
358 $user_attr->setRequired(
true);
359 $form->addItem($user_attr);
369 if (!$form->checkInput()) {
370 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
371 $form->setValuesByPost();
377 if (!empty($form->getInput(
'scopes'))) {
378 $scopes = $form->getInput(
'scopes');
387 switch ((
int) $form->getInput(
'validate_scopes')) {
389 $discoveryURL = $form->getInput(
'provider') .
'/.well-known/openid-configuration';
392 $discoveryURL = $form->getInput(
'custom_discovery_url');
395 $discoveryURL = null;
398 $validation_result = !is_null($discoveryURL) ? $this->
settings->validateScopes($discoveryURL, (array)
$scopes) : [];
400 if (!empty($validation_result)) {
404 sprintf($this->
lng->txt(
'auth_oidc_settings_invalid_scopes'), implode(
",", $validation_result[1]))
409 sprintf($this->
lng->txt(
'auth_oidc_settings_discovery_error'), $validation_result[1])
412 $form->setValuesByPost();
421 $form->setValuesByPost();
426 $this->
settings->setActive((
bool) $form->getInput(
'activation'));
427 $this->
settings->setProvider((
string) $form->getInput(
'provider'));
428 $this->
settings->setClientId((
string) $form->getInput(
'client_id'));
429 if ((
string) $form->getInput(
'secret') !==
'' && strcmp($form->getInput(
'secret'),
'******') !== 0) {
430 $this->
settings->setSecret((
string) $form->getInput(
'secret'));
433 $this->
settings->setLoginElementType((
int) $form->getInput(
'le'));
434 $this->
settings->setLoginElementText((
string) $form->getInput(
'le_text'));
435 $this->
settings->setLoginPromptType((
int) $form->getInput(
'login_prompt'));
436 $this->
settings->setLogoutScope((
int) $form->getInput(
'logout_scope'));
437 $this->
settings->useCustomSession((
bool) $form->getInput(
'custom_session'));
438 $this->
settings->setSessionDuration((
int) $form->getInput(
'session_duration'));
439 $this->
settings->allowSync((
bool) $form->getInput(
'sync'));
440 $this->
settings->setRole((
int) $form->getInput(
'role'));
441 $this->
settings->setUidField((
string) $form->getInput(
'username'));
443 $fileData = (array) $form->getInput(
'le_img');
445 if ((
string) ($fileData[
'tmp_name'] ??
'') !==
'') {
449 $this->
settings->setValidateScopes((
int) $form->getInput(
'validate_scopes'));
451 $this->
settings->setCustomDiscoveryUrl($form->getInput(
'custom_discovery_url'));
455 $this->
mainTemplate->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
456 $this->
ctrl->redirect($this,
'settings');
462 if (!$this->
upload->hasBeenProcessed()) {
465 foreach ($this->
upload->getResults() as $single_file_upload) {
466 if ($single_file_upload->isOK()) {
468 $this->
upload->moveFilesTo(
472 $this->
settings->setLoginElementImage($single_file_upload->getName());
476 $this->
logger->warning(
'Upload failed with message: ' . $e->getMessage());
487 $this->review->getGlobalRoles(),
494 if ($a_with_select_option) {
495 $select[0] = $this->
lng->txt(
'links_select_one');
497 foreach ($global_roles as $role_id) {
521 $form->setTitle($this->
lng->txt(
'auth_oidc_mapping_table'));
522 $form->setFormAction($this->
ctrl->getFormAction($this,
'saveProfile'));
524 foreach ($this->
settings->getProfileMappingFields() as $field => $lng_key) {
526 $text_form->setPostVar($field .
"_value");
527 $text_form->setValue($this->
settings->getProfileMappingFieldValue($field));
528 $form->addItem($text_form);
531 $checkbox_form->setValue(
"1");
532 $checkbox_form->setPostVar($field .
"_update");
533 $checkbox_form->setChecked($this->
settings->getProfileMappingFieldUpdate($field));
534 $checkbox_form->setOptionTitle($this->
lng->txt(
'auth_oidc_update_field_info'));
535 $form->addItem($checkbox_form);
539 $form->addCommandButton(
'saveProfile', $this->
lng->txt(
'save'));
550 if (!$form->checkInput()) {
551 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
552 $form->setValuesByPost();
557 foreach ($this->
settings->getProfileMappingFields() as $field => $lng_key) {
558 $this->
settings->setProfileMappingFieldValue(
560 $form->getInput($field .
'_value')
562 $this->
settings->setProfileMappingFieldUpdate(
564 (
bool) $form->getInput($field .
'_update')
568 $this->
mainTemplate->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
569 $this->
ctrl->redirect($this, self::STAB_PROFILE);
586 $form->setTitle($this->
lng->txt(
'auth_oidc_role_mapping_table'));
587 $form->setFormAction($this->
ctrl->getFormAction($this, self::STAB_ROLES));
592 'role_map_' . $role_id
594 $role_map->setInfo($this->
lng->txt(
'auth_oidc_role_info'));
595 $role_map->setValue($this->
settings->getRoleMappingValueForId((
int) $role_id));
596 $form->addItem($role_map);
600 'role_map_update_' . $role_id
602 $update->setOptionTitle($this->
lng->txt(
'auth_oidc_update_role_info'));
604 $update->setChecked(!$this->
settings->getRoleMappingUpdateForId((
int) $role_id));
609 $form->addCommandButton(
'saveRoles', $this->
lng->txt(
'save'));
618 if ($form->checkInput()) {
625 $role_settings[(
int) $role_id][
'update'] = !$form->getInput(
'role_map_update_' . $role_id);
626 $role_settings[(
int) $role_id][
'value'] =
'';
628 $input_role = trim($form->getInput(
'role_map_' . $role_id));
629 if ($input_role ===
'') {
633 $role_params = explode(
'::', $input_role);
636 if (count($role_params) !== 2) {
637 if ($form->getItemByPostVar(
'role_map_' . $role_id)) {
638 $form->getItemByPostVar(
'role_map_' . $role_id)->setAlert($this->
lng->txt(
'msg_wrong_format'));
643 $role_settings[(
int) $role_id][
'value'] = $input_role;
647 $form->setValuesByPost();
648 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
653 $this->
settings->setRoleMappings($role_settings);
655 $this->
mainTemplate->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
656 $this->
ctrl->redirect($this,
'roles');
659 $form->setValuesByPost();
660 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
666 $this->
tabs->addSubTab(
668 $this->
lng->txt(
'auth_oidc_' . self::STAB_SETTINGS),
669 $this->
ctrl->getLinkTarget($this, self::STAB_SETTINGS)
671 $this->
tabs->addSubTab(
673 $this->
lng->txt(
'auth_oidc_' . self::STAB_PROFILE),
674 $this->
ctrl->getLinkTarget($this, self::STAB_PROFILE)
676 $this->
tabs->addSubTab(
678 $this->
lng->txt(
'auth_oidc_' . self::STAB_ROLES),
679 $this->
ctrl->getLinkTarget($this, self::STAB_ROLES)
682 $this->
tabs->activateSubTab($active_tab);
settings(ilPropertyFormGUI $form=null)
setSubTabs(string $active_tab)
const URL_VALIDATION_NONE
checkAccessBool(string $a_permission)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_ref_id)
const LOGOUT_SCOPE_GLOBAL
saveImageFromHttpRequest()
Class ilOpenIdConnectSettingsGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
prepareRoleSelection(bool $a_with_select_option=true)
checkAccess(string $a_permission)
Class ChatMainBarProvider .
const URL_VALIDATION_PROVIDER
roles(ilPropertyFormGUI $form=null)
const LOGIN_ELEMENT_TYPE_TXT
ilGlobalTemplateInterface $mainTemplate
ilOpenIdConnectSettings $settings
profile(ilPropertyFormGUI $form=null)
static _lookupTitle(int $obj_id)
const VALIDATION_ISSUE_INVALID_SCOPE
static _sortIds(array $a_ids, string $a_table, string $a_field, string $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),'usr_data','lastname','usr_id') => sorts by lastname.
Error Handling & global info handling uses PEAR error class.
const URL_VALIDATION_CUSTOM
const LOGIN_ELEMENT_TYPE_IMG
Class FlySystemFileAccessTest disabled disabled disabled.