Skip to content

Commit d073a53

Browse files
committed
added: setting to disable forced sso on explicit logout action
1 parent 79332a9 commit d073a53

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed

classes/ColdTrick/SAMLSSO/Logout.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace ColdTrick\SAMLSSO;
4+
5+
use Elgg\Http\ResponseBuilder;
6+
use Elgg\Http\OkResponse;
7+
8+
class Logout {
9+
10+
/**
11+
* Disable forced SSO login after a logout
12+
*
13+
* @param \Elgg\Hook $hook 'response', 'action:logout'
14+
*
15+
* @return null|ResponseBuilder
16+
*/
17+
public static function disableSso(\Elgg\Hook $hook): ?ResponseBuilder {
18+
19+
$response = $hook->getValue();
20+
if (!$response instanceof OkResponse) {
21+
return null;
22+
}
23+
24+
if (!(bool) elgg_get_plugin_setting('disable_sso_on_logout', 'saml_sso')) {
25+
return null;
26+
}
27+
28+
$forward = $response->getForwardURL() ?: elgg_get_site_url();
29+
$forward = elgg_http_add_url_query_elements($forward, [
30+
'disable_sso' => 1,
31+
]);
32+
33+
$response->setForwardURL($forward);
34+
35+
return $response;
36+
}
37+
}

elgg-plugin.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
],
1010
'settings' => [
1111
'use_http_x_forwarded' => 0,
12+
'disable_sso_on_logout' => false,
1213
],
1314
'entities' => [
1415
[
@@ -55,7 +56,12 @@
5556
'menu:page' => [
5657
'\ColdTrick\SAMLSSO\Menus::registerAdminPageMenu' => [],
5758
],
58-
]
59+
],
60+
'response' => [
61+
'action:logout' => [
62+
'\ColdTrick\SAMLSSO\Logout::disableSso' => [],
63+
],
64+
],
5965
],
6066
'actions' => [
6167
'saml_sso/add_idp_from_xml' => [

languages/en.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
'saml_sso:settings:use_http_x_forwarded' => "Use proxy variables",
88
'saml_sso:settings:use_http_x_forwarded:help' => "Allow the usage of HTTP_X_FORWARDED server information",
9+
'saml_sso:settings:disable_sso_on_logout' => "Disable SSO on logout",
10+
'saml_sso:settings:disable_sso_on_logout:help' => "Enabling this will prevent forced SSO for users that explicitely use the logout action",
911

1012
'add:object:saml_idp' => "Create IDP",
1113
'add:object:saml_idp:from_xml' => "Create IDP from XML",

languages/nl.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
'admin:configure_utilities:manage_idps' => 'Beheer SAML IDPs',
1010
'saml_sso:settings:use_http_x_forwarded' => 'Gebruik proxy variabelen',
1111
'saml_sso:settings:use_http_x_forwarded:help' => 'Sta het gebruik toe van de HTTP_X_FORWARDED server informatie',
12+
'saml_sso:settings:disable_sso_on_logout' => 'SSO uitschakelen na afmelden',
13+
'saml_sso:settings:disable_sso_on_logout:help' => 'Indien dit actief is zal er geen SSO geforceerd worden wanneer een gebruiker zich expliciet heeft afgemeld',
1214
'add:object:saml_idp' => 'Maak IDP',
1315
'add:object:saml_idp:from_xml' => 'Maak IDP obv XML',
1416
'saml_sso:add_from_xml:url' => 'Voer IDP metadata URL in voor autodetectie',

views/default/plugins/saml_sso/settings.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@
1616
'default' => 0,
1717
'value' => 1,
1818
]);
19+
20+
echo elgg_view_field([
21+
'#type' => 'checkbox',
22+
'#label' => elgg_echo('saml_sso:settings:disable_sso_on_logout'),
23+
'#help' => elgg_echo('saml_sso:settings:disable_sso_on_logout:help'),
24+
'name' => 'params[disable_sso_on_logout]',
25+
'checked' => (bool) $plugin->disable_sso_on_logout,
26+
'switch' => true,
27+
'default' => 0,
28+
'value' => 1,
29+
]);

0 commit comments

Comments
 (0)