19declare(strict_types=1);
65 'hide_own_online_status',
75 'interests_help_offered',
76 'interests_help_looking',
77 'bs_allow_to_contact_me',
78 'chat_osc_accept_msg',
79 'chat_broadcast_typing',
102 $this->
ctrl = $DIC->ctrl();
103 $this->tpl =
$DIC->ui()->mainTemplate();
104 $this->
lng = $DIC->language();
105 $this->
access = $DIC->access();
106 $this->
rbac = $DIC->rbac();
107 $this->error_handler =
$DIC[
'ilErr'];
108 $this->
tabs = $DIC->tabs();
109 $this->
toolbar = $DIC[
'ilToolbar'];
110 $this->
help = $DIC[
'ilHelp'];
111 $this->httpState =
$DIC->http();
114 $this->
lng->loadLanguageModule(
'auth');
120 if (!$this->
rbac->system()->checkAccess($operation, $this->getRefId())) {
121 $this->error_handler->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error_handler->WARNING);
143 if ($this->httpState->wrapper()->query()->has(
'saml_idp_id')) {
144 $idpId = (
int) $this->httpState->wrapper()->query()->retrieve(
148 } elseif ($this->httpState->wrapper()->post()->has(
'saml_idp_id')) {
149 $idpId = (
int) $this->httpState->wrapper()->post()->retrieve(
162 }
catch (Exception
$e) {
163 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'auth_saml_unknow_idp'),
true);
164 $this->
ctrl->setParameter($this,
'saml_idp_id',
null);
165 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
176 }
catch (Throwable
$e) {
177 if (
'Database error: could not find driver' ===
$e->getMessage()) {
178 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'auth_saml_err_sqlite_driver'));
180 $this->tpl->setOnScreenMessage(
'failure',
$e->getMessage());
184 $this->
help->setScreenIdComponent(
'auth');
186 switch ($this->
ctrl->getNextClass()) {
188 $cmd = $this->
ctrl->getCmd();
189 if ($cmd ===
null || $cmd ===
'' || !method_exists($this, $cmd)) {
195 $this->
ctrl->saveParameter($this,
'saml_idp_id');
198 if (!in_array(strtolower($cmd), array_map(
'strtolower', self::$globalCommands),
true)) {
200 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
208 in_array(strtolower($cmd), array_map(
'strtolower', self::$globalCommands),
true) ||
209 in_array(strtolower($cmd), array_map(
'strtolower', self::$globalEntityCommands),
true)
223 if ($this->samlAuth && $this->
rbac->system()->checkAccess(
'write', $this->ref_id)) {
225 $addIdpButton->setCaption(
'auth_saml_add_idp_btn');
226 $addIdpButton->setUrl($this->
ctrl->getLinkTarget($this,
'showNewIdpForm'));
227 $this->
toolbar->addStickyItem($addIdpButton);
233 $this->
rbac->system()->checkAccess(
'write', $this->getRefId())
235 $this->tpl->setContent($table->getHTML());
242 $this->idp->setActive(
false);
243 $this->idp->persist();
245 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
253 $this->idp->setActive(
true);
254 $this->idp->persist();
256 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
262 switch ($a_view_mode) {
264 $this->
tabs->addSubTabTarget(
266 $this->
ctrl->getLinkTarget($this, self::DEFAULT_CMD),
267 array_merge(self::$globalEntityCommands, [self::DEFAULT_CMD,
'showNewIdpForm',
'saveNewIdp']),
271 $this->
tabs->addSubTabTarget(
273 $this->
ctrl->getLinkTarget($this,
'showSettings'),
274 [
'showSettings',
'saveSettings'],
280 $this->
tabs->clearTargets();
281 $this->
tabs->setBackTarget(
282 $this->
lng->txt(
'back'),
283 $this->ctrl->getLinkTarget($this, self::DEFAULT_CMD)
286 $this->
tabs->addSubTabTarget(
287 'auth_saml_idp_settings',
288 $this->
ctrl->getLinkTarget($this,
'showIdpSettings'),
289 [
'showIdpSettings',
'saveIdpSettings'],
293 $this->
tabs->addSubTabTarget(
294 'auth_saml_user_mapping',
295 $this->
ctrl->getLinkTarget($this,
'showUserAttributeMappingForm'),
296 [
'showUserAttributeMappingForm',
'saveUserAttributeMapping'],
311 $form->setFormAction($this->
ctrl->getFormAction($this,
'saveUserAttributeMapping'));
312 $form->setTitle($this->
lng->txt(
'auth_saml_user_mapping'));
315 foreach ($usr_profile->getStandardFields() as
$id => $definition) {
316 if (in_array(
$id, self::$ignoredUserFields,
true)) {
327 if (!$this->
access->checkAccess(
'write',
'', $this->getRefId())) {
328 foreach ($form->getItems() as $item) {
329 $item->setDisabled(
true);
332 $form->addCommandButton(
'saveUserAttributeMapping', $this->
lng->txt(
'save'));
347 $update_automatically->setOptionTitle($this->
lng->txt(
'auth_saml_update_field_info'));
348 $update_automatically->setValue(
'1');
349 $form->
addItem($update_automatically);
354 $this->ensureWriteAccess();
356 $form = $this->getUserAttributeMappingForm();
358 $this->mapping->delete();
361 foreach ($usr_profile->getStandardFields() as
$id => $definition) {
362 if (in_array(
$id, self::$ignoredUserFields,
true)) {
366 $rule = $this->mapping->getEmptyRule();
367 $rule->setAttribute(
$id);
368 $rule->setExternalAttribute((
string) $form->
getInput($rule->getAttribute()));
369 $rule->updateAutomatically((
bool) $form->
getInput($rule->getAttribute() .
'_update'));
370 $this->mapping[$rule->getAttribute()] = $rule;
374 $rule = $this->mapping->getEmptyRule();
375 $rule->setAttribute(
'udf_' . $definition[
'field_id']);
376 $rule->setExternalAttribute((
string) $form->
getInput($rule->getAttribute()));
377 $rule->updateAutomatically((
bool) $form->
getInput($rule->getAttribute() .
'_update'));
378 $this->mapping[$rule->getAttribute()] = $rule;
381 $this->mapping->save();
383 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
388 $this->showUserAttributeMappingForm($form);
393 $this->
tabs->setSubTabActive(
'auth_saml_user_mapping');
396 $form = $this->getUserAttributeMappingForm();
398 foreach ($this->mapping as $rule) {
399 $data[$rule->getAttribute()] = $rule->getExternalAttribute();
400 $data[$rule->getAttribute() .
'_update'] = $rule->isAutomaticallyUpdated();
405 $this->tpl->setContent($form->
getHTML());
412 $form->
setTitle($this->
lng->txt(
'auth_saml_configure'));
415 $show_login_form->setInfo($this->
lng->txt(
'auth_saml_login_form_info'));
416 $show_login_form->setValue(
'1');
417 $form->
addItem($show_login_form);
419 if (!$this->
access->checkAccess(
'write',
'', $this->getRefId())) {
420 foreach ($form->
getItems() as $item) {
421 $item->setDisabled(
true);
436 $this->
rbac->review()->getGlobalRoles(),
442 $select[0] = $this->
lng->txt(
'links_select_one');
443 foreach ($global_roles as $role_id) {
452 $this->ensureWriteAccess();
454 $form = $this->getSettingsForm();
457 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
462 $this->showSettings($form);
468 $form = $this->getSettingsForm();
474 $this->tpl->setContent($form->
getHTML());
481 $form->
setTitle(sprintf($this->
lng->txt(
'auth_saml_configure_idp'), $this->idp->getEntityId()));
484 $idp->setDisabled(
true);
487 $this->addMetadataElement($form);
490 $local->setValue(
'1');
491 $local->setInfo($this->
lng->txt(
'auth_allow_local_info'));
494 $uid_claim =
new ilTextInputGUI($this->
lng->txt(
'auth_saml_uid_claim'),
'uid_claim');
495 $uid_claim->setInfo($this->
lng->txt(
'auth_saml_uid_claim_info'));
496 $uid_claim->setRequired(
true);
500 $sync->setInfo($this->
lng->txt(
'auth_saml_sync_info'));
501 $sync->setValue(
'1');
503 $username_claim =
new ilTextInputGUI($this->
lng->txt(
'auth_saml_username_claim'),
'login_claim');
504 $username_claim->setInfo($this->
lng->txt(
'auth_saml_username_claim_info'));
505 $username_claim->setRequired(
true);
506 $sync->addSubItem($username_claim);
509 $role->setOptions($this->prepareRoleSelection());
510 $role->setRequired(
true);
511 $sync->addSubItem($role);
514 $migr->setInfo($this->
lng->txt(
'auth_saml_migration_info'));
515 $migr->setValue(
'1');
516 $sync->addSubItem($migr);
519 if (!$this->
access->checkAccess(
'write',
'', $this->getRefId())) {
520 foreach ($form->
getItems() as $item) {
521 $item->setDisabled(
true);
533 $this->
tabs->setSubTabActive(
'auth_saml_idp_settings');
535 if (
null === $form) {
536 $form = $this->getIdpSettingsForm();
537 $data = $this->idp->toArray();
538 $this->populateWithMetadata($this->idp,
$data);
544 $this->
help->setSubScreenId(
'edit_idp');
546 $this->tpl->setContent($form->
getHTML());
551 $this->ensureWriteAccess();
553 $form = $this->getIdpSettingsForm();
555 $this->idp->bindForm($form);
556 $this->idp->persist();
557 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
559 $this->storeMetadata($this->idp, $form->
getInput(
'metadata'));
562 $this->showIdpSettings($form);
569 $form->
setTitle($this->
lng->txt(
'auth_saml_add_idp_btn'));
571 $this->addMetadataElement($form);
581 $this->ensureWriteAccess();
583 $form = $this->getIdpForm();
586 $idp->bindForm($form);
589 $this->storeMetadata($idp, $form->
getInput(
'metadata'));
591 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
592 $this->
ctrl->setParameter($this,
'saml_idp_id', $idp->
getIdpId());
593 $this->
ctrl->redirect($this,
'showIdpSettings');
596 $this->showNewIdpForm($form);
601 $this->ensureWriteAccess();
603 if (
null === $form) {
604 $form = $this->getIdpForm();
609 $this->
help->setSubScreenId(
'create_idp');
611 $this->tpl->setContent($form->
getHTML());
617 $this->
lng->txt(
'auth_saml_add_idp_md_label'),
624 $metadata->setInfo($this->
lng->txt(
'auth_saml_add_idp_md_info'));
625 $metadata->setRows(20);
626 $metadata->setRequired(
true);
631 $metadata->setPurifier($purifier);
632 $metadata->usePurifier(
true);
638 $idpDisco = $this->samlAuth->getIdpDiscovery();
640 $data[
'metadata'] = $idpDisco->fetchIdpMetadata($idp->
getIdpId());
645 $idpDisco = $this->samlAuth->getIdpDiscovery();
646 $idpDisco->storeIdpMetadata($idp->
getIdpId(), $metadata);
651 $this->ensureWriteAccess();
654 $confirmation->setFormAction($this->
ctrl->getFormAction($this,
'deleteIdp'));
655 $confirmation->setConfirm($this->
lng->txt(
'confirm'),
'deleteIdp');
656 $confirmation->setCancel($this->
lng->txt(
'cancel'), self::DEFAULT_CMD);
657 $confirmation->setHeaderText($this->
lng->txt(
'auth_saml_sure_delete_idp'));
658 $confirmation->addItem(
'saml_idp_ids', (
string) $this->idp->getIdpId(), $this->idp->getEntityId());
660 $this->tpl->setContent($confirmation->getHTML());
665 $this->ensureWriteAccess();
667 $idpDisco = $this->samlAuth->getIdpDiscovery();
668 $idpDisco->deleteIdpMetadata($this->idp->getIdpId());
670 $this->idp->delete();
672 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'auth_saml_deleted_idp'),
true);
674 $this->
ctrl->setParameter($this,
'saml_idp_id',
null);
675 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Provides fluid interface to RBAC services.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Error Handling & global info handling uses PEAR error class.
Class ilExternalAuthUserAttributeMapping.
Composite for nesting multiple purifiers.
static _lookupTitle(int $obj_id)
static getInstanceByIdpId(int $a_idp_id)
addAttributeRuleFieldToForm(ilPropertyFormGUI $form, string $field_label, string $field_name)
populateWithMetadata(ilSamlIdp $idp, array &$data)
setSubTabs(int $a_view_mode)
static array $globalEntityCommands
showNewIdpForm(ilPropertyFormGUI $form=null)
ilGlobalTemplateInterface $tpl
initUserAttributeMapping()
GlobalHttpState $httpState
storeMetadata(ilSamlIdp $idp, string $metadata)
ensureAccess(string $operation)
ilErrorHandling $error_handler
showUserAttributeMappingForm(ilPropertyFormGUI $form=null)
showSettings(ilPropertyFormGUI $form=null)
showIdpSettings(ilPropertyFormGUI $form=null)
static array $globalCommands
ilExternalAuthUserAttributeMapping $mapping
addMetadataElement(ilPropertyFormGUI $form)
static array $ignoredUserFields
saveUserAttributeMapping()
getUserAttributeMappingForm()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.
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,...
Interface GlobalHttpState.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...