Making WordPress.org


Ignore:
Timestamp:
07/16/2025 02:29:30 AM (13 months ago)
Author:
dd32
Message:

SSO: Improve the logout process for non-WordPress domains (Such as BuddyPress and WordCamp).

This resolves some edge-cases where if your cookies on WordPress.org & WordCamp.org became out-of-sync using two different sessions (or you lost your wporg cookies, but retained wcorg) it would become impossible to logout properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/wporg-sso/wp-plugin.php

    r14446 r14486  
    582582                        );
    583583
     584                        /*
     585                         * If we're not on the SSO cookie host, clear the cookies locally before redirecting.
     586                         * Upon redirect back, these previous cookies should be invalid as the session is destroyed.
     587                         */
     588                        if ( $this->sso_cookie_host !== COOKIE_DOMAIN ) {
     589                                wp_clear_auth_cookie();
     590                        }
     591
    584592                        $this->_safe_redirect( $remote_logout_url );
    585593                        exit;
     
    686694                /**
    687695                 * Log out a user and destroy the session.
     696                 *
     697                 * NOTE: This handles `action=remote-logout` requests. The remote-logout query var
     698                 *       is not actually used, but is present as a legacy of previous implementations.
    688699                 */
    689700                protected function _maybe_perform_remote_logout() {
     
    699710                        }
    700711
    701                         // Perform the logout. This will destroy the session, logging the user out of all sites.
     712                        // If the session noted in the remote-logout is different from current, destroy that session first.
     713                        $current_token = wp_get_session_token();
     714                        if (
     715                                $remote_token['session_token'] &&
     716                                wp_get_session_token() !== $remote_token['session_token']
     717                        ) {
     718                                $manager = WP_Session_Tokens::get_instance( $remote_token['user']->ID );
     719                                $manager->destroy( $remote_token['session_token'] );
     720                        }
     721
     722                        // Perform the logout. This will destroy the *current* session, logging the user out of all sites.
    702723                        wp_logout();
    703724
Note: See TracChangeset for help on using the changeset viewer.