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

Fix logout process #453

Merged
merged 4 commits into from
May 3, 2018
Merged

Fix logout process #453

merged 4 commits into from
May 3, 2018

Conversation

joshcanhelp
Copy link
Contributor

  • Remove federated logout for SSO (heavy-handed and was causing issues with some users)
  • Remove end_session method call (we're not setting any sessions so we should not be deleting any either)
  • Fix telemetry header issues (fixes Encode auth0Client in login redirect URL #448)
  • Fix SLO link empty issue (get_permalink() is empty on non-post pages)
  • Fix improper filter handling in auth0_sso_footer (cannot echo in filters, must return modified data)
  • Add no_sso check for SSO footer on wp-login.php to skip SSO processing if there was a login error (can cause redirect loops)
  • Minor code quality fixes (calling out internal methods

@joshcanhelp joshcanhelp added this to the v3-Next milestone May 1, 2018
$this->a0_options->get( 'domain' ),
rawurlencode( home_url() ),
$this->a0_options->get( 'client_id' ),
$telemetry_headers['Auth0-Client']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find any GH issues created for refactoring this usage. Are you tracking this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's in Jira

} else {
$redirect_url = home_url();
}
wp_redirect( $redirect_url );
exit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this line $is_sso and $is_auto_login were not used and the function is already returning. Would it make sense to define those variables right above the line that uses it? Would that help this code perform better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's less clear and $this->a0_options->get() is just returning an array value so I don't think optimization there is helpful.

exit;
}

if ( $auto_login ) {
// If auto-login is in use, cannot redirect back to login page.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"login page" would be the "authorize page" / HLP?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is the WP login page. Auto-login forwards to /authorize with a connection param so we need to drop folks logging out somewhere else.

return;
// No need to checkSession if already logged in.
// URL parameter `no_sso` is set to skip checkSession.
if ( is_user_logged_in() || ! empty( $_GET['no_sso'] ) || ! $this->a0_options->get( 'sso' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is like the negative (!) of the negative (empty) of the negative (no_). Should this be extracted to a variable for readability ?

include WPA0_PLUGIN_DIR . 'templates/auth0-sso-handler-lock10.php';
}
wp_enqueue_script( 'wpa0_auth0js', $this->a0_options->get( 'auth0js-cdn' ) );
ob_start();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this? Can't find it in this diff. Also the one ob_get_clean()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ob_start() is output buffer, ob_get_clean() returns the buffer and clears it out. This is used to "capture" an echo basically

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you're creating a new buffer and putting in the contents of the 'templates/auth0-sso-handler-lock10.php' file, and returning $previous_html plus the buffer contents?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I would rather this be in an external JS file since it's doing something similar to the implicit flow we have as part of the plugin but this is all being removed on the next minor in favor of UL so I don't want to waste time on it.

@@ -578,8 +588,6 @@ public function auth0_singlelogout_footer() {

/**
* End the PHP session.
*
* TODO: Remove, not necessary!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is necessary now or what?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be deprecated, added that comment below 👇

@@ -664,7 +672,7 @@ protected function die_on_login( $msg = '', $code = 0, $login_link = true ) {
: __( 'Please see the site administrator', 'wp-auth0' ),
__( 'error code', 'wp-auth0' ),
$code ? sanitize_text_field( $code ) : __( 'unknown', 'wp-auth0' ),
$login_link ? wp_login_url() : wp_logout_url(),
$login_link ? add_query_arg( 'no_sso', 1, wp_login_url() ) : wp_logout_url(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so add_query_arg will return the modified URL?

Remove federated logout for SSO. Fix SLO link empty issue. Minor code
quality fixes.
return;
// No need to checkSession if already logged in.
// URL parameter `skip_sso` is set to skip checkSession.
if ( is_user_logged_in() || isset( $_GET['skip_sso'] ) || ! $this->a0_options->get( 'sso' ) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is like the negative (!) of the negative (empty) of the negative (no_). Should this be extracted to a variable for readability ?

I liked your suggestion here so I changed the param name and now just checking if it's there.

Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants