Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow wp-login.php query variables to be filtered #35

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions onelogin-saml-sso/onelogin_saml.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function disable_password_reset() { return false; }
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';

// Handle SLO
if (isset($_COOKIE['saml_login']) && get_option('onelogin_saml_slo')) {
if (isset($_COOKIE['saml_login']) && get_option('onelogin_saml_slo')) {
add_action('init', 'saml_slo', 1);
}

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

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

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

if (($want_to_local_login && $prevent_local_login) || ($want_to_reset && $prevent_reset_password)) {
if (($want_to_local_login && $prevent_local_login) || ($want_to_reset && $prevent_reset_password)) {
$execute_sso = True;
}
}
Expand Down
6 changes: 4 additions & 2 deletions onelogin-saml-sso/php/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@

function onelogin_saml_configuration_render() {
$title = __("SSO/SAML Settings", 'onelogin-saml-sso');
$saml_metadata = apply_filters( 'onelogin_saml_metadata', 'saml_metadata' );
$saml_validate_config = apply_filters( 'onelogin_saml_validate_config', 'saml_validate_config' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<div class="alignleft">
<a href="http://www.onelogin.com"><img src="<?php echo plugins_url('onelogin.png', dirname(__FILE__));?>"></a>
</div>
<div class="alignright">
<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>
<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>
<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>
<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>
</div>
<div style="clear:both"></div>
<h2><?php echo esc_html( $title ); ?></h2>
Expand Down
16 changes: 12 additions & 4 deletions onelogin-saml-sso/php/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@


function saml_checker() {
if (isset($_GET['saml_acs'])) {
/**
* Allow saml_acs query variables to be customized.
*/
$saml_acs = apply_filters( 'onelogin_saml_acs', 'saml_acs' );
$saml_sls = apply_filters( 'onelogin_saml_sls', 'saml_sls' );
$saml_metadata = apply_filters( 'onelogin_saml_metadata', 'saml_metadata' );
$saml_validate_config = apply_filters( 'onelogin_saml_validate_config', 'saml_validate_config' );

if ( isset( $_GET[ $saml_acs ] ) ) {
saml_acs();
}
else if (isset($_GET['saml_sls'])) {
else if (isset($_GET[ $saml_sls ])) {
saml_sls();
} else if (isset($_GET['saml_metadata'])) {
} else if (isset($_GET[ $saml_metadata ])) {
saml_metadata();
} else if (isset($_GET['saml_validate_config'])) {
} else if (isset($_GET[ $saml_validate_config ])) {
saml_validate_config();
}
}
Expand Down
9 changes: 7 additions & 2 deletions onelogin-saml-sso/php/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@
}
}

$acs_endpoint = get_option('onelogin_saml_alternative_acs', false) ? plugins_url( 'alternative_acs.php', dirname( __FILE__ ) ) : wp_login_url() . '?saml_acs';
/**
* Allow saml_acs URL query variable to be customized.
*/
$saml_acs = apply_filters( 'onelogin_saml_acs', 'saml_acs' );
$saml_sls = apply_filters( 'onelogin_saml_acs', 'saml_sls' );
$acs_endpoint = get_option( 'onelogin_saml_alternative_acs', false ) ? plugins_url( 'alternative_acs.php', dirname( __FILE__ ) ) : wp_login_url() . '?' . $saml_acs;

$settings = array (

Expand All @@ -70,7 +75,7 @@
'url' => $acs_endpoint
),
'singleLogoutService' => array (
'url' => get_site_url().'/wp-login.php?saml_sls'
'url' => get_site_url( null, '/wp-login.php?' . $saml_sls )
),
'NameIDFormat' => $opt['NameIDFormat'],
'x509cert' => get_option('onelogin_saml_advanced_settings_sp_x509cert'),
Expand Down