Skip to content

Commit 40c1e7e

Browse files
authored
Merge pull request #3 from jazzsequence/feature/saml-url-filters
Allow wp-login.php query variables to be filtered
2 parents ecf2001 + e553009 commit 40c1e7e

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

onelogin-saml-sso/onelogin_saml.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function disable_password_reset() { return false; }
3939
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
4040

4141
// Handle SLO
42-
if (isset($_COOKIE['saml_login']) && get_option('onelogin_saml_slo')) {
42+
if (isset($_COOKIE['saml_login']) && get_option('onelogin_saml_slo')) {
4343
add_action('init', 'saml_slo', 1);
4444
}
4545

@@ -48,7 +48,8 @@ function disable_password_reset() { return false; }
4848
add_action('init', 'saml_sso', 1);
4949
} else {
5050
$execute_sso = false;
51-
$saml_actions = isset($_GET['saml_metadata']) || (strpos($_SERVER['SCRIPT_NAME'], 'alternative_acs.php') !== FALSE);
51+
$saml_metadata = apply_filters( 'onelogin_saml_metadata', 'saml_metadata' );
52+
$saml_actions = isset($_GET[ $saml_metadata ]) || (strpos($_SERVER['SCRIPT_NAME'], 'alternative_acs.php') !== FALSE);
5253

5354
$wp_login_page = (strpos($_SERVER['SCRIPT_NAME'], 'wp-login.php') !== FALSE) && $action == 'login' && !isset($_GET['loggedout']);
5455

@@ -69,7 +70,7 @@ function disable_password_reset() { return false; }
6970
} else if ($local_wp_actions) {
7071
$prevent_local_login = get_option('onelogin_saml_customize_action_prevent_local_login', false);
7172

72-
if (($want_to_local_login && $prevent_local_login) || ($want_to_reset && $prevent_reset_password)) {
73+
if (($want_to_local_login && $prevent_local_login) || ($want_to_reset && $prevent_reset_password)) {
7374
$execute_sso = True;
7475
}
7576
}

onelogin-saml-sso/php/configuration.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313

1414
function onelogin_saml_configuration_render() {
1515
$title = __("SSO/SAML Settings", 'onelogin-saml-sso');
16+
$saml_metadata = apply_filters( 'onelogin_saml_metadata', 'saml_metadata' );
17+
$saml_validate_config = apply_filters( 'onelogin_saml_validate_config', 'saml_validate_config' );
1618
?>
1719
<div class="wrap">
1820
<?php screen_icon(); ?>
1921
<div class="alignleft">
2022
<a href="http://www.onelogin.com"><img src="<?php echo plugins_url('onelogin.png', dirname(__FILE__));?>"></a>
2123
</div>
2224
<div class="alignright">
23-
<a href="<?php echo get_site_url().'/wp-login.php?saml_metadata'; ?>" target="blank"><?php echo __("Go to the metadata of this SP", 'onelogin-saml-sso');?></a><br>
24-
<a href="<?php echo get_site_url().'/wp-login.php?saml_validate_config'; ?>" target="blank"><?php echo __("Once configured, validate here your OneLogin SSO/SAML Settings", 'onelogin-saml-sso');?></a>
25+
<a href="<?php echo get_site_url( null, '/wp-login.php?' . $saml_metadata ); ?>" target="blank"><?php echo __("Go to the metadata of this SP", 'onelogin-saml-sso');?></a><br>
26+
<a href="<?php echo get_site_url( null, '/wp-login.php?' . $saml_validate_config ); ?>" target="blank"><?php echo __("Once configured, validate here your OneLogin SSO/SAML Settings", 'onelogin-saml-sso');?></a>
2527
</div>
2628
<div style="clear:both"></div>
2729
<h2><?php echo esc_html( $title ); ?></h2>

onelogin-saml-sso/php/functions.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@
1010

1111

1212
function saml_checker() {
13-
if (isset($_GET['saml_acs'])) {
13+
/**
14+
* Allow saml_acs query variables to be customized.
15+
*/
16+
$saml_acs = apply_filters( 'onelogin_saml_acs', 'saml_acs' );
17+
$saml_sls = apply_filters( 'onelogin_saml_sls', 'saml_sls' );
18+
$saml_metadata = apply_filters( 'onelogin_saml_metadata', 'saml_metadata' );
19+
$saml_validate_config = apply_filters( 'onelogin_saml_validate_config', 'saml_validate_config' );
20+
21+
if ( isset( $_GET[ $saml_acs ] ) ) {
1422
saml_acs();
1523
}
16-
else if (isset($_GET['saml_sls'])) {
24+
else if (isset($_GET[ $saml_sls ])) {
1725
saml_sls();
18-
} else if (isset($_GET['saml_metadata'])) {
26+
} else if (isset($_GET[ $saml_metadata ])) {
1927
saml_metadata();
20-
} else if (isset($_GET['saml_validate_config'])) {
28+
} else if (isset($_GET[ $saml_validate_config ])) {
2129
saml_validate_config();
2230
}
2331
}

onelogin-saml-sso/php/settings.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@
5757
}
5858
}
5959

60-
$acs_endpoint = get_option('onelogin_saml_alternative_acs', false) ? plugins_url( 'alternative_acs.php', dirname( __FILE__ ) ) : wp_login_url() . '?saml_acs';
60+
/**
61+
* Allow saml_acs URL query variable to be customized.
62+
*/
63+
$saml_acs = apply_filters( 'onelogin_saml_acs', 'saml_acs' );
64+
$saml_sls = apply_filters( 'onelogin_saml_acs', 'saml_sls' );
65+
$acs_endpoint = get_option( 'onelogin_saml_alternative_acs', false ) ? plugins_url( 'alternative_acs.php', dirname( __FILE__ ) ) : wp_login_url() . '?' . $saml_acs;
6166

6267
$settings = array (
6368

@@ -70,7 +75,7 @@
7075
'url' => $acs_endpoint
7176
),
7277
'singleLogoutService' => array (
73-
'url' => get_site_url().'/wp-login.php?saml_sls'
78+
'url' => get_site_url( null, '/wp-login.php?' . $saml_sls )
7479
),
7580
'NameIDFormat' => $opt['NameIDFormat'],
7681
'x509cert' => get_option('onelogin_saml_advanced_settings_sp_x509cert'),

0 commit comments

Comments
 (0)