Skip to content

Commit

Permalink
added: feature to configure if IDP should show up on login form
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalsem committed Oct 12, 2020
1 parent 9110932 commit 17a073b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions actions/saml_sso/edit_idp.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
}

$idp->title = get_input('title');
$idp->description = get_input('description');
$idp->sso_url = get_input('sso_url');
$idp->slo_url = get_input('slo_url');
$idp->x509cert = get_input('x509cert');
$idp->private_key = get_input('private_key');
$idp->show_on_login_form = (int) get_input('show_on_login_form');

return elgg_ok_response();
4 changes: 4 additions & 0 deletions classes/ColdTrick/SAMLSSO/Menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public static function registerLoginMenu(\Elgg\Hook $hook) {
$return = $hook->getValue();

foreach ($entities as $entity) {
if (!$entity->showOnLoginForm()) {
continue;
}

$id = $entity->getIDPID();
$return[] = \ElggMenuItem::factory([
'name' => "login_{$id}",
Expand Down
9 changes: 9 additions & 0 deletions classes/SAMLIDP.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ public function getIDPID() {
return 'idp_' . elgg_get_friendly_title($this->getDisplayName());
}

/**
* Checks if this IDP should show on the login form
*
* @return bool
*/
public function showOnLoginForm() {
return $this->show_on_login_form !== 0;
}

/**
* Return an SAML settings array
*
Expand Down
1 change: 1 addition & 0 deletions languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'saml_sso:saml_idp:slo_url' => "Single Log Out URL",
'saml_sso:saml_idp:x509cert' => "x509 Certificate",
'saml_sso:saml_idp:private_key' => "Private Key",
'saml_sso:saml_idp:show_on_login_form' => "Show on login form",

'saml_sso:force_authentication' => "Forced Authentication",
'saml_sso:force_authentication:enable' => "Enable Forced Authentication",
Expand Down
18 changes: 18 additions & 0 deletions views/default/forms/saml_sso/edit_idp.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
'value' => $entity ? $entity->title : null,
]);

echo elgg_view_field([
'#type' => 'plaintext',
'#label' => elgg_echo('description'),
'name' => 'description',
'value' => $entity ? $entity->description : null,
'rows' => 3,
]);

if ($entity && $entity->settings) {
echo elgg_format_element('pre', [], var_export(unserialize($entity->settings), true));

Expand Down Expand Up @@ -52,6 +60,16 @@
'value' => $entity ? $entity->private_key : null,
]);

echo elgg_view_field([
'#type' => 'checkbox',
'#label' => elgg_echo('saml_sso:saml_idp:show_on_login_form'),
'name' => 'show_on_login_form',
'checked' => $entity->show_on_login_form !== 0,
'switch' => true,
'default' => 0,
'value' => 1,
]);

$footer = elgg_view_field([
'#type' => 'submit',
'value' => elgg_echo('save'),
Expand Down
1 change: 1 addition & 0 deletions views/default/object/saml_idp.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'byline' => false,
'access' => false,
'imprint' => $imprint,
'content' => $entity->description,
];
$params = $params + $vars;
echo elgg_view('object/elements/summary', $params);

0 comments on commit 17a073b

Please sign in to comment.