Making WordPress.org


Ignore:
Timestamp:
11/11/2022 05:10:24 AM (4 years ago)
Author:
dd32
Message:

Login: SSO: When you logout from a WordPress.org network, logout from all networks.

This causes a logout on wordcamp.org to log you out of wordpress.org and vice-versa.

This is needed as WordPress.org doesn't use shared Sessions with WordCamp.org, BuddyPress.org, and bbPress.org, but shares credentials and a central login screen.

File:
1 edited

Legend:

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

    r12238 r12239  
    1212                const LOGIN_TOS_COOKIE  = 'wporg_tos_login';
    1313                const TOS_USER_META_KEY = 'tos_revision';
     14
     15                /**
     16                 * The time SSO tokens are valid. These are used for remote login/logout on
     17                 * non-wordpress.org domains.
     18                 *
     19                 * @var int
     20                 */
     21                const REMOTE_TOKEN_TIMEOUT = 5;
    1422
    1523                const VALID_HOSTS = [
     
    186194                 * Tests if the passed host/domain, or URL, is part of the WordPress.org network.
    187195                 *
    188                  * @param unknown $host A domain, hostname, or URL
     196                 * @param string $host A domain, hostname, or URL
    189197                 * @return boolean True is ok, false if not
    190198                 */
     
    202210                        }
    203211
     212                        $host = $this->_get_targetted_host( $host );
     213
     214                        return in_array( $host, self::VALID_HOSTS, true );
     215                }
     216
     217                /**
     218                 * Determine the targetted hostname for a given hostname.
     219                 *
     220                 * This returns 'wordpress.org' in the case of 'login.wordpress.org'.
     221                 * This does NOT validate the hostname is valid for a redirect.
     222                 *
     223                 * @param string $host The hostname to process.
     224                 * @return string The hostname, maybe top-level, maybe not.
     225                 */
     226                protected function _get_targetted_host( $host ) {
    204227                        if ( in_array( $host, self::VALID_HOSTS, true ) ) {
    205                                 return true;
     228                                return $host;
    206229                        }
    207230
    208231                        // If not a top-level domain, shrink it down and try again.
    209232                        $top_level_host = implode( '.', array_slice( explode( '.', $host ), -2 ) );
    210 
    211                         return in_array( $top_level_host, self::VALID_HOSTS, true );
     233                        if ( in_array( $top_level_host, self::VALID_HOSTS, true ) ) {
     234                                $host = $top_level_host;
     235                        }
     236
     237                        return $host;
    212238                }
    213239
Note: See TracChangeset for help on using the changeset viewer.