Skip to content

Commit

Permalink
Merge pull request #113 from pantheon-systems/111-persist-redirect-to
Browse files Browse the repository at this point in the history
Persist `redirect_to` value in a more accurate manner
  • Loading branch information
danielbachhuber authored Feb 13, 2018
2 parents ebaa7a5 + 1e3862b commit 5013989
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**Tags:** authentication, SAML
**Requires at least:** 4.4
**Tested up to:** 4.9
**Stable tag:** 0.3.6
**Stable tag:** 0.3.7
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -253,6 +253,9 @@ There is no third step. Because SimpleSAMLphp loads WordPress, which has WP Nati

## Changelog ##

### 0.3.7 (February 13, 2018) ###
* Persists `redirect_to` value in a more accurate manner, as a follow up to the change in v0.3.6 [[#113](https://github.com/pantheon-systems/wp-saml-auth/pull/113)].

### 0.3.6 (February 7, 2018) ###
* Prevents WordPress from dropping authentication cookie when user is redirected to login from `/wp-admin/` URLs [[#112](https://github.com/pantheon-systems/wp-saml-auth/pull/112)].

Expand Down
14 changes: 11 additions & 3 deletions inc/class-wp-saml-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,19 @@ public function do_saml_authentication() {
$this->provider->login( $redirect_to );
}
} elseif ( is_a( $this->provider, 'SimpleSAML_Auth_Simple' ) ) {
$redirect_to = filter_input( INPUT_GET, 'redirect_to', FILTER_SANITIZE_URL );
if ( $redirect_to ) {
$redirect_to = add_query_arg( 'redirect_to', $redirect_to, wp_login_url() );
} else {
$redirect_to = wp_login_url();
// Only persist redirect_to when it's not wp-login.php.
if ( false === stripos( $redirect_to, $_SERVER['REQUEST_URI'] ) ) {
$redirect_to = add_query_arg( 'redirect_to', $_SERVER['REQUEST_URI'], $redirect_to );
}
}
$this->provider->requireAuth(
array(
// Prevent WordPress from dropping the login cookie
// when REQUEST_URI is /wp-admin/.
'ReturnTo' => str_replace( '&reauth=1', '', $_SERVER['REQUEST_URI'] ),
'ReturnTo' => $redirect_to,
)
);
$attributes = $this->provider->getAttributes();
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: getpantheon, danielbachhuber, Outlandish Josh
Tags: authentication, SAML
Requires at least: 4.4
Tested up to: 4.9
Stable tag: 0.3.6
Stable tag: 0.3.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -253,6 +253,9 @@ There is no third step. Because SimpleSAMLphp loads WordPress, which has WP Nati

== Changelog ==

= 0.3.7 (February 13, 2018) =
* Persists `redirect_to` value in a more accurate manner, as a follow up to the change in v0.3.6 [[#113](https://github.com/pantheon-systems/wp-saml-auth/pull/113)].

= 0.3.6 (February 7, 2018) =
* Prevents WordPress from dropping authentication cookie when user is redirected to login from `/wp-admin/` URLs [[#112](https://github.com/pantheon-systems/wp-saml-auth/pull/112)].

Expand Down
2 changes: 1 addition & 1 deletion wp-saml-auth.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: WP SAML Auth
* Version: 0.3.6
* Version: 0.3.7
* Description: SAML authentication for WordPress, using SimpleSAMLphp.
* Author: Pantheon
* Author URI: https://pantheon.io
Expand Down

0 comments on commit 5013989

Please sign in to comment.