1<?
php declare(strict_types=1);
43 'hide_own_online_status',
53 'interests_help_offered',
54 'interests_help_looking',
55 'bs_allow_to_contact_me',
56 'chat_osc_accept_msg',
94 $this->ctrl =
$DIC->ctrl();
95 $this->tpl =
$DIC->ui()->mainTemplate();
96 $this->lng =
$DIC->language();
97 $this->access =
$DIC->access();
98 $this->rbac =
$DIC->rbac();
99 $this->error_handler =
$DIC[
'ilErr'];
100 $this->tabs =
$DIC->tabs();
101 $this->toolbar =
$DIC[
'ilToolbar'];
102 $this->
help = $DIC[
'ilHelp'];
104 $this->lng->loadLanguageModule(
'auth');
113 if (!$this->rbac->system()->checkAccess($operation, $this->getRefId())) {
114 $this->error_handler->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->error_handler->WARNING);
148 }
catch (Exception
$e) {
150 $this->ctrl->setParameter($this,
'saml_idp_id',
null);
151 $this->ctrl->redirect($this, self::DEFAULT_CMD);
162 }
catch (Throwable
$e) {
163 if (
'Database error: could not find driver' ===
$e->getMessage()) {
170 $this->
help->setScreenIdComponent(
'auth');
172 switch ($this->ctrl->getNextClass()) {
174 $cmd = $this->ctrl->getCmd();
175 if (!strlen($cmd) || !method_exists($this, $cmd)) {
179 if (isset($_REQUEST[
'saml_idp_id'])) {
180 $this->ctrl->saveParameter($this,
'saml_idp_id');
183 if (!in_array(strtolower($cmd), array_map(
'strtolower', self::$globalCommands))) {
184 if (!isset($_REQUEST[
'saml_idp_id'])) {
185 $this->ctrl->redirect($this, self::DEFAULT_CMD);
193 in_array(strtolower($cmd), array_map(
'strtolower', self::$globalCommands)) ||
194 in_array(strtolower($cmd), array_map(
'strtolower', self::$globalEntityCommands))
211 if ($this->samlAuth && $this->rbac->system()->checkAccess(
'visible,read', $this->ref_id)) {
213 $addIdpButton->setCaption(
'auth_saml_add_idp_btn');
214 $addIdpButton->setUrl($this->ctrl->getLinkTarget($this,
'showNewIdpForm'));
215 $this->toolbar->addStickyItem($addIdpButton);
219 $this->tpl->setContent($table->getHTML());
226 $this->idp->setActive(
false);
227 $this->idp->persist();
229 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
237 $this->idp->setActive(
true);
238 $this->idp->persist();
240 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
249 switch ($a_view_mode) {
251 $this->tabs->addSubTabTarget(
253 $this->ctrl->getLinkTarget($this, self::DEFAULT_CMD),
254 array_merge(self::$globalEntityCommands, [self::DEFAULT_CMD,
'showNewIdpForm',
'saveNewIdp']),
258 $this->tabs->addSubTabTarget(
260 $this->ctrl->getLinkTarget($this,
'showSettings'),
261 array(
'showSettings',
'saveSettings'),
267 $this->tabs->clearTargets();
268 $this->tabs->setBackTarget(
269 $this->lng->txt(
'back'),
270 $this->ctrl->getLinkTarget($this, self::DEFAULT_CMD)
273 $this->tabs->addSubTabTarget(
274 'auth_saml_idp_settings',
275 $this->ctrl->getLinkTarget($this,
'showIdpSettings'),
276 [
'showIdpSettings',
'saveIdpSettings'],
280 $this->tabs->addSubTabTarget(
281 'auth_saml_user_mapping',
282 $this->ctrl->getLinkTarget($this,
'showUserAttributeMappingForm'),
283 [
'showUserAttributeMappingForm',
'saveUserAttributeMapping'],
301 $form->setFormAction($this->ctrl->getFormAction($this,
'saveUserAttributeMapping'));
302 $form->setTitle($this->lng->txt(
'auth_saml_user_mapping'));
305 foreach ($usr_profile->getStandardFields() as $id => $definition) {
306 if (in_array($id, self::$ignoredUserFields)) {
317 if (!$this->access->checkAccess(
'write',
'', $this->getRefId())) {
318 foreach ($form->getItems() as $item) {
319 $item->setDisabled(
true);
322 $form->addCommandButton(
'saveUserAttributeMapping', $this->lng->txt(
'save'));
342 $update_automatically->setOptionTitle($this->lng->txt(
'auth_saml_update_field_info'));
343 $update_automatically->setValue(1);
344 $form->
addItem($update_automatically);
349 $this->ensureWriteAccess();
351 $form = $this->getUserAttributeMappingForm();
353 $this->mapping->delete();
356 foreach ($usr_profile->getStandardFields() as $id => $definition) {
357 if (in_array($id, self::$ignoredUserFields)) {
361 $rule = $this->mapping->getEmptyRule();
362 $rule->setAttribute($id);
363 $rule->setExternalAttribute($form->
getInput($rule->getAttribute()));
364 $rule->updateAutomatically((
bool) $form->
getInput($rule->getAttribute() .
'_update'));
365 $this->mapping[$rule->getAttribute()] = $rule;
369 $rule = $this->mapping->getEmptyRule();
370 $rule->setAttribute(
'udf_' . $definition[
'field_id']);
371 $rule->setExternalAttribute($form->
getInput($rule->getAttribute()));
372 $rule->updateAutomatically((
bool) $form->
getInput($rule->getAttribute() .
'_update'));
373 $this->mapping[$rule->getAttribute()] = $rule;
376 $this->mapping->save();
378 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
383 $this->showUserAttributeMappingForm($form);
391 $this->tabs->setSubTabActive(
'auth_saml_user_mapping');
394 $form = $this->getUserAttributeMappingForm();
396 foreach ($this->mapping as $rule) {
397 $data[$rule->getAttribute()] = $rule->getExternalAttribute();
398 $data[$rule->getAttribute() .
'_update'] = (bool) $rule->isAutomaticallyUpdated();
403 $this->tpl->setContent($form->
getHTML());
412 $form->
setFormAction($this->ctrl->getFormAction($this,
'saveSettings'));
413 $form->
setTitle($this->lng->txt(
'auth_saml_configure'));
415 $show_login_form =
new ilCheckboxInputGUI($this->lng->txt(
'auth_saml_login_form'),
'login_form');
416 $show_login_form->setInfo($this->lng->txt(
'auth_saml_login_form_info'));
417 $show_login_form->setValue(1);
418 $form->
addItem($show_login_form);
420 if (!$this->access->checkAccess(
'write',
'', $this->getRefId())) {
421 foreach ($form->
getItems() as $item) {
422 $item->setDisabled(
true);
434 $this->rbac->review()->getGlobalRoles(),
440 $select[0] = $this->lng->txt(
'links_select_one');
441 foreach ($global_roles as $role_id) {
450 $this->ensureWriteAccess();
452 $form = $this->getSettingsForm();
455 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
460 $this->showSettings($form);
469 $form = $this->getSettingsForm();
475 $this->tpl->setContent($form->
getHTML());
484 $form->
setFormAction($this->ctrl->getFormAction($this,
'saveIdpSettings'));
485 $form->
setTitle(sprintf($this->lng->txt(
'auth_saml_configure_idp'), $this->idp->getEntityId()));
487 $idp =
new ilTextInputGUI($this->lng->txt(
'auth_saml_idp'),
'entity_id');
488 $idp->setDisabled(
true);
491 $this->addMetadataElement($form);
493 $local =
new ilCheckboxInputGUI($this->lng->txt(
'auth_allow_local'),
'allow_local_auth');
495 $local->setInfo($this->lng->txt(
'auth_allow_local_info'));
498 $uid_claim =
new ilTextInputGUI($this->lng->txt(
'auth_saml_uid_claim'),
'uid_claim');
499 $uid_claim->setInfo($this->lng->txt(
'auth_saml_uid_claim_info'));
500 $uid_claim->setRequired(
true);
504 $sync->setInfo($this->lng->txt(
'auth_saml_sync_info'));
507 $username_claim =
new ilTextInputGUI($this->lng->txt(
'auth_saml_username_claim'),
'login_claim');
508 $username_claim->setInfo($this->lng->txt(
'auth_saml_username_claim_info'));
509 $username_claim->setRequired(
true);
510 $sync->addSubItem($username_claim);
512 $role =
new ilSelectInputGUI($this->lng->txt(
'auth_saml_role_select'),
'default_role_id');
513 $role->setOptions($this->prepareRoleSelection());
514 $role->setRequired(
true);
515 $sync->addSubItem($role);
517 $migr =
new ilCheckboxInputGUI($this->lng->txt(
'auth_saml_migration'),
'account_migr_status');
518 $migr->setInfo($this->lng->txt(
'auth_saml_migration_info'));
520 $sync->addSubItem($migr);
523 if (!$this->access->checkAccess(
'write',
'', $this->getRefId())) {
524 foreach ($form->
getItems() as $item) {
525 $item->setDisabled(
true);
540 $this->tabs->setSubTabActive(
'auth_saml_idp_settings');
542 if (
null === $form) {
543 $form = $this->getIdpSettingsForm();
544 $data = $this->idp->toArray();
545 $this->populateWithMetadata($this->idp,
$data);
551 $this->
help->setSubScreenId(
'edit_idp');
553 $this->tpl->setContent($form->
getHTML());
558 $this->ensureWriteAccess();
560 $form = $this->getIdpSettingsForm();
562 $this->idp->bindForm($form);
563 $this->idp->persist();
564 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
566 $this->storeMetadata($this->idp, $form->
getInput(
'metadata'));
569 $this->showIdpSettings($form);
578 $form->
setFormAction($this->ctrl->getFormAction($this,
'saveNewIdp'));
579 $form->
setTitle($this->lng->txt(
'auth_saml_add_idp_btn'));
581 $this->addMetadataElement($form);
591 $this->ensureWriteAccess();
593 $form = $this->getIdpForm();
596 $idp->bindForm($form);
599 $this->storeMetadata($idp, $form->
getInput(
'metadata'));
601 ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'),
true);
602 $this->ctrl->setParameter($this,
'saml_idp_id', $idp->getIdpId());
603 $this->ctrl->redirect($this,
'showIdpSettings');
606 $this->showNewIdpForm($form);
614 $this->ensureWriteAccess();
616 if (
null === $form) {
617 $form = $this->getIdpForm();
622 $this->
help->setSubScreenId(
'create_idp');
624 $this->tpl->setContent($form->
getHTML());
633 $this->lng->txt(
'auth_saml_add_idp_md_label'),
637 $metadata->setInfo($this->lng->txt(
'auth_saml_add_idp_md_info'));
638 $metadata->setRows(20);
639 $metadata->setRequired(
true);
644 $metadata->setPurifier($purifier);
645 $metadata->usePurifier(
true);
651 $idpDisco = $this->samlAuth->getIdpDiscovery();
653 $data[
'metadata'] = $idpDisco->fetchIdpMetadata($idp->
getIdpId());
662 $idpDisco = $this->samlAuth->getIdpDiscovery();
663 $idpDisco->storeIdpMetadata($idp->
getIdpId(), $metadata);
668 $this->ensureWriteAccess();
671 $confirmation->setFormAction($this->ctrl->getFormAction($this,
'deleteIdp'));
672 $confirmation->setConfirm($this->lng->txt(
'confirm'),
'deleteIdp');
673 $confirmation->setCancel($this->lng->txt(
'cancel'), self::DEFAULT_CMD);
674 $confirmation->setHeaderText($this->lng->txt(
'auth_saml_sure_delete_idp'));
675 $confirmation->addItem(
'saml_idp_ids', $this->idp->getIdpId(), $this->idp->getEntityId());
677 $this->tpl->setContent($confirmation->getHTML());
682 $this->ensureWriteAccess();
684 $idpDisco = $this->samlAuth->getIdpDiscovery();
685 $idpDisco->deleteIdpMetadata($this->idp->getIdpId());
687 $this->idp->delete();
689 ilUtil::sendSuccess($this->lng->txt(
'auth_saml_deleted_idp'),
true);
691 $this->ctrl->setParameter($this,
'saml_idp_id',
null);
692 $this->ctrl->redirect($this, self::DEFAULT_CMD);
An exception for terminatinating execution or to throw for unit testing.
Confirmation screen class.
Class ilExternalAuthUserAttributeMapping.
Composite for nesting multiple purifiers.
static _lookupTitle($a_id)
lookup object title
static getInstanceByIdpId(int $a_idp_id)
static $ignoredUserFields
addAttributeRuleFieldToForm(ilPropertyFormGUI $form, string $field_label, string $field_name)
populateWithMetadata(ilSamlIdp $idp, array &$data)
setSubTabs(int $a_view_mode)
showNewIdpForm(ilPropertyFormGUI $form=null)
initUserAttributeMapping()
storeMetadata(ilSamlIdp $idp, string $metadata)
ensureAccess(string $operation)
static $globalEntityCommands
showUserAttributeMappingForm(ilPropertyFormGUI $form=null)
showSettings(ilPropertyFormGUI $form=null)
showIdpSettings(ilPropertyFormGUI $form=null)
__construct($ref_id)
ilSamlSettingsGUI constructor.
addMetadataElement(ilPropertyFormGUI $form)
saveUserAttributeMapping()
getUserAttributeMappingForm()
This class represents a text property in a property form.
static _getInstance()
Get instance.
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,...
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.