Skip to content

Commit f81feef

Browse files
committed
Release 2.6.0. Add Status setting in order to enable or disable the plugin (Required on multi-sites environment since the plugin is enabled globally for the network)
1 parent 6e35829 commit f81feef

File tree

6 files changed

+79
-20
lines changed

6 files changed

+79
-20
lines changed

onelogin-saml-sso/onelogin_saml.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin URI: https://github.com/onelogin/wordpress-saml
55
Description: Give users secure one-click access to WordPress from OneLogin. This SAML integration eliminates passwords and allows you to authenticate users against your existing Active Directory or LDAP server as well increase security using YubiKeys or VeriSign VIP Access, browser PKI certificates and OneLogin's flexible security policies. OneLogin is pre-integrated with thousands of apps and handles all of your SSO needs in the cloud and behind the firewall.
66
Author: OneLogin, Inc.
7-
Version: 2.5.0
7+
Version: 2.6.0
88
Author URI: http://www.onelogin.com
99
*/
1010

@@ -14,6 +14,22 @@
1414
exit;
1515
}
1616

17+
require_once plugin_dir_path(__FILE__)."php/functions.php";
18+
require_once plugin_dir_path(__FILE__)."php/configuration.php";
19+
20+
// Localization
21+
add_action( 'init', 'saml_load_translations');
22+
23+
// add menu option for configuration
24+
add_action('admin_menu', 'onelogin_saml_configuration');
25+
26+
// Check if exists SAML Messages
27+
add_action('init', 'saml_checker', 1);
28+
29+
if (!is_saml_enabled()) {
30+
return;
31+
}
32+
1733
// Allow cookie name overriding by defining following constants prior this point. Eg.: in wp-config.php.
1834
if ( false === defined( 'SAML_LOGIN_COOKIE' ) ) {
1935
define( 'SAML_LOGIN_COOKIE', 'saml_login' );
@@ -28,18 +44,6 @@
2844
define( 'SAML_NAMEID_FORMAT_COOKIE', 'saml_nameid_format' );
2945
}
3046

31-
require_once plugin_dir_path(__FILE__)."php/functions.php";
32-
require_once plugin_dir_path(__FILE__)."php/configuration.php";
33-
34-
// Localization
35-
add_action( 'init', 'saml_load_translations');
36-
37-
// Check if exists SAML Messages
38-
add_action('init', 'saml_checker', 1);
39-
40-
// add menu option for configuration
41-
add_action('admin_menu', 'onelogin_saml_configuration');
42-
4347
$prevent_reset_password = get_option('onelogin_saml_customize_action_prevent_reset_password', false);
4448
if ($prevent_reset_password) {
4549
add_filter ('allow_password_reset', 'disable_password_reset' );

onelogin-saml-sso/php/configuration.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ function onelogin_saml_configuration() {
5050

5151
$option_group = 'onelogin_saml_configuration';
5252

53+
add_settings_section('status', __('STATUS', 'onelogin-saml-sso'), 'plugin_section_status_text', $option_group);
54+
55+
register_setting($option_group, 'onelogin_saml_enabled');
56+
add_settings_field('onelogin_saml_enabled', __('Enable', 'onelogin-saml-sso'), "plugin_setting_boolean_onelogin_saml_enabled", $option_group, 'status');
57+
5358
add_settings_section('idp', __('IDENTITY PROVIDER SETTINGS', 'onelogin-saml-sso'), 'plugin_section_idp_text', $option_group);
5459
$idp_fields = array (
5560
'onelogin_saml_idp_entityid' => __('IdP Entity Id', 'onelogin-saml-sso') . ' *',
@@ -182,6 +187,13 @@ function onelogin_saml_configuration() {
182187
add_settings_field('onelogin_saml_advanced_digestalgorithm', __('Digest Algorithm', 'onelogin-saml-sso'), "plugin_setting_select_onelogin_saml_advanced_digestalgorithm", $option_group, 'advanced_settings');
183188
}
184189

190+
function plugin_setting_boolean_onelogin_saml_enabled() {
191+
$value = get_option('onelogin_saml_enabled');
192+
echo '<input type="checkbox" name="onelogin_saml_enabled" id="onelogin_saml_enabled"
193+
'.($value ? 'checked="checked"': '').'>'.
194+
'<p class="description">'.__("Check it in order to enable the SAML plugin.", 'onelogin-saml-sso').'</p>';
195+
}
196+
185197
function plugin_setting_string_onelogin_saml_idp_entityid() {
186198
echo '<input type="text" name="onelogin_saml_idp_entityid" id="onelogin_saml_idp_entityid"
187199
value= "'.esc_attr(get_option('onelogin_saml_idp_entityid')).'" size="80">'.

onelogin-saml-sso/php/functions.php

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
require_once "compatibility.php";
1010

11-
1211
function saml_checker() {
1312
if (isset($_GET['saml_acs'])) {
1413
if (empty($_POST['SAMLResponse'])) {
@@ -68,6 +67,10 @@ function saml_sso() {
6867
return true;
6968
}
7069
$auth = initialize_saml();
70+
if ($auth == false) {
71+
wp_redirect(home_url());
72+
exit();
73+
}
7174
if (isset($_SERVER['REQUEST_URI']) && !isset($_GET['saml_sso'])) {
7275
$auth->login($_SERVER['REQUEST_URI']);
7376
} else {
@@ -99,6 +102,10 @@ function saml_slo() {
99102
}
100103

101104
$auth = initialize_saml();
105+
if ($auth == false) {
106+
wp_redirect(home_url());
107+
exit();
108+
}
102109
$auth->logout(home_url(), array(), $nameId, $sessionIndex, false, $nameIdFormat);
103110
return false;
104111
}
@@ -136,6 +143,10 @@ function saml_role_order_compare($role1, $role2) {
136143

137144
function saml_acs() {
138145
$auth = initialize_saml();
146+
if ($auth == false) {
147+
wp_redirect(home_url());
148+
exit();
149+
}
139150

140151
$auth->processResponse();
141152

@@ -311,6 +322,11 @@ function saml_acs() {
311322

312323
function saml_sls() {
313324
$auth = initialize_saml();
325+
if ($auth == false) {
326+
wp_redirect(home_url());
327+
exit();
328+
}
329+
314330
$retrieve_parameters_from_server = get_option('onelogin_saml_advanced_settings_retrieve_parameters_from_server', false);
315331
if (isset($_GET) && isset($_GET['SAMLRequest'])) {
316332
// Close session before send the LogoutResponse to the IdP
@@ -370,6 +386,10 @@ function initialize_saml() {
370386
require_once plugin_dir_path(__FILE__).'_toolkit_loader.php';
371387
require plugin_dir_path(__FILE__).'settings.php';
372388

389+
if (!is_saml_enabled()) {
390+
return false;
391+
}
392+
373393
try {
374394
$auth = new Onelogin_Saml2_Auth($settings);
375395
} catch (Exception $e) {
@@ -382,6 +402,23 @@ function initialize_saml() {
382402
return $auth;
383403
}
384404

405+
function is_saml_enabled() {
406+
$saml_enabled = get_option('onelogin_saml_enabled', null);
407+
if ($saml_enabled == null) {
408+
// If no data was saved about enable/disable saml, then
409+
// check if entityId also is null and then consider the
410+
// plugin disabled
411+
if (get_option('onelogin_saml_idp_entityid', null) == null) {
412+
$saml_enabled = false;
413+
} else {
414+
$saml_enabled = true;
415+
}
416+
} else {
417+
$saml_enabled = $saml_enabled == 'on'? true : false;
418+
}
419+
return $saml_enabled;
420+
}
421+
385422
// Prevent that the user change important fields
386423
class preventLocalChanges
387424
{
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"php-saml": {
3-
"version": "2.11.0",
4-
"released": "21/07/2017"
3+
"version": "2.13.0",
4+
"released": "05/03/2018"
55
}
66
}

onelogin-saml-sso/readme.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ If you used this plugin before 2.2.0 with just-in-time provision active, Read: h
2121
To mitigate that bug, place the script at the root of wordpress and execute it (later remove it) https://gist.github.com/pitbulk/a8223c90a3534e9a7d5e0a93009a094f
2222

2323
== Changelog ==
24+
= 2.6.0 =
25+
* Update php-saml to 2.13.0
26+
* Add Status setting in order to enable or disable the plugin (Required on multi-sites environment since the plugin is enabled globally for the network)
27+
* Add 'Remember Me' Login option to Settings
28+
* Fix bug on escaping value for customize_links_saml_login
29+
* If password is disabled.. turn field readonly.. not disable it
2430

2531
= 2.5.0 =
2632
* Update php-saml library to 2.11.0

onelogin-saml-sso/version.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"php-saml": {
3-
"version": "2.11.0",
4-
"released": "21/07/2017"
3+
"version": "2.13.0",
4+
"released": "05/05/2018"
55
},
66
"plugin": {
77
"app": "wordpress",
88
"name": "onelogin-saml-sso",
9-
"version": "2.5.0",
10-
"released": "02/08/2017"
9+
"version": "2.6.0",
10+
"released": "18/05/2018"
1111
}
1212
}

0 commit comments

Comments
 (0)