<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[2098] sites/trunk/common/includes: login.wordpress.org: Initial open sourcing of our upcoming Single Sign-On library, to be used across our sites, as well as the related generic WordPress, bbPress, and GlotPress plugins.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/2098">2098</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/2098","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>stephdau</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-11-20 17:35:17 +0000 (Fri, 20 Nov 2015)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>login.wordpress.org: Initial open sourcing of our upcoming Single Sign-On library, to be used across our sites, as well as the related generic WordPress, bbPress, and GlotPress plugins.

See <a href="http://meta.trac.wordpress.org/ticket/1406">#1406</a></pre>

<h3>Added Paths</h3>
<ul>
<li>sites/trunk/common/includes/wporg-sso/</li>
<li><a href="#sitestrunkcommonincludeswporgssobbpluginphp">sites/trunk/common/includes/wporg-sso/bb-plugin.php</a></li>
<li><a href="#sitestrunkcommonincludeswporgssoclasswporgssophp">sites/trunk/common/includes/wporg-sso/class-wporg-sso.php</a></li>
<li><a href="#sitestrunkcommonincludeswporgssogppluginphp">sites/trunk/common/includes/wporg-sso/gp-plugin.php</a></li>
<li><a href="#sitestrunkcommonincludeswporgssowppluginphp">sites/trunk/common/includes/wporg-sso/wp-plugin.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkcommonincludeswporgssobbpluginphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/common/includes/wporg-sso/bb-plugin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/common/includes/wporg-sso/bb-plugin.php                               (rev 0)
+++ sites/trunk/common/includes/wporg-sso/bb-plugin.php 2015-11-20 17:35:17 UTC (rev 2098)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,55 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * bbPress-specific WPORG SSO: redirects all BB login and registration screens to our SSO ones.
+ * 
+ * @uses WPOrg_SSO (class-wporg-sso.php)
+ * @author stephdau
+ */
+if ( ! class_exists( 'WPOrg_SSO' ) ) {
+       require_once __DIR__ . '/class-wporg-sso.php';
+}
+
+if ( class_exists( 'WPOrg_SSO' ) && ! class_exists( 'BB_WPOrg_SSO' ) ) {
+       class BB_WPOrg_SSO extends WPOrg_SSO {
+               /**
+                * Constructor: add our action(s)/filter(s)
+                */
+               public function __construct() {
+                       parent::__construct();
+
+                       add_action( 'bb_init', array( &$this, 'redirect_all_login_or_signup_to_sso' ) );
+               }
+               
+               /**
+                * Redirect all attempts to get to a BB login or signup to the SSO ones, or to a safe redirect location.
+                * 
+                * @example add_action( 'bb_init', array( &$wporg_sso, 'redirect_all_bb_login_or_signup_to_sso' ) );
+                */
+               function redirect_all_login_or_signup_to_sso() {
+                       if ( ! $this->_is_valid_targeted_domain( $this->host ) ) {
+                               // Not in list of targeted domains, not interested, bail out.
+                               return;
+                       } else if ( preg_match( '/\/register\.php$/', $this->script ) ) {
+                               // Redirect registration request to the one we want to standardize on.
+                               if ( "https://{$this->host}{$this->script}" !== $this->sso_signup_url ) {
+                                       $this->_safe_redirect( $this->sso_signup_url );
+                               }
+                       } else if ( preg_match( '/\/bb-login\.php$/', $this->script ) ) {
+                               $redirect_to_sso_login = $this->sso_login_url;
+                                       
+                               // Pass thru the requested action, loggedout, if any
+                               if ( ! empty( $_GET ) ) {
+                                       $redirect_to_sso_login = add_query_arg( $_GET, $redirect_to_sso_login );
+                               }
+                                       
+                               // Pay extra attention to the post-process redirect_to
+                               $redirect_to_sso_login = add_query_arg( 'redirect_to', $this->_get_safer_redirect_to(), $redirect_to_sso_login );
+                               
+                               // Redirect to SSO login, trying to pass on a decent redirect_to request.
+                               $this->_safe_redirect( $redirect_to_sso_login );
+                       }
+               }
+       }
+       
+       new BB_WPOrg_SSO();
+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/common/includes/wporg-sso/bb-plugin.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkcommonincludeswporgssoclasswporgssophp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/common/includes/wporg-sso/class-wporg-sso.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/common/includes/wporg-sso/class-wporg-sso.php                         (rev 0)
+++ sites/trunk/common/includes/wporg-sso/class-wporg-sso.php   2015-11-20 17:35:17 UTC (rev 2098)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,157 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+if ( ! class_exists( 'WPOrg_SSO' ) ) {
+       /**
+        * Single Sign-On (SSO) handling for WordPress/bbPress/GlotPress instances under *.wordpress.org.
+        * 
+        * @author stephdau
+        */
+       class WPOrg_SSO {
+               const SSO_HOST = 'login.wordpress.org';
+               
+               public $sso_host_url;
+               public $sso_login_url;
+               public $sso_signup_url;
+               
+               public $host;
+               public $script;
+               
+               /**
+                * Constructor, instantiate common properties
+                */
+               public function __construct() {
+                       $this->sso_host_url   = 'https://' . self::SSO_HOST;
+                       $this->sso_login_url  = $this->sso_host_url . '/wp-login.php';
+                       $this->sso_signup_url = 'https://wordpress.org/support/register.php'; // For now
+                       
+                       $this->host   = $_SERVER['HTTP_HOST'];
+                       $this->script = $_SERVER['SCRIPT_NAME'];
+               }
+               
+               /**
+                * Checks if the requested redirect_to URL is part of the wordpress.org empire, adds it as an redirect host if so.
+                *
+                * @param array $hosts Currently allowed hosts
+                * @return array $hosts Edited lists of allowed hosts
+                * 
+                * @example add_filter( 'allowed_redirect_hosts', array( &$this, 'add_allowed_redirect_host' ) );
+               */
+               public function add_allowed_redirect_host( $hosts ) {
+                       if ( self::SSO_HOST === $this->host ) {
+                               // If on the SSO host, add the requesting source (eg: make.wordpress.org), if within our bounds
+                               $url  = parse_url( $this->_get_safer_redirect_to() );
+                               $host = ( empty( $url ) ) ? null : $url['host'];
+                       } else {
+                               // If not on the SSO host, add login.wordpress.org, to be safe
+                               $host = self::SSO_HOST;
+                       }
+               
+                       // If we got a host by now, it's a safe wordpress.org-based one, add it to the list of allowed redirects
+                       if ( ! empty( $host ) && ! in_array( $host, $hosts ) ){
+                               $hosts[] = $host;
+                       }
+               
+                       // Return list of allowed hosts
+                       return $hosts;
+               }
+               
+               /**
+                * Returns the SSO login URL, with redirect_to as requested, if deemed valid.
+                * 
+                * @param string $redirect_to
+                * @param string $filter_redirect_to When used with the WP login_url filter, the redirect_to is passed as a 2nd arg instead.
+                * @return string
+                * 
+                * @example Use directly, or through add_action( 'login_url', array( &$wporg_sso, 'login_url' ), 10, 2 );
+                */
+               public function login_url( $redirect_to = '', $filter_redirect_to = '' ) {
+                       $login_url = $this->sso_login_url;
+                       // If 2nd arg is passed, then redirect_to is it.
+                       if ( ! empty( $filter_redirect_to ) ) {
+                               $redirect_to = $filter_redirect_to;
+                       }
+                       if ( ! empty( $redirect_to ) && $this->_is_valid_targeted_domain( $redirect_to ) ) {
+                               $redirect_to = preg_replace( '/\/wp-(login|signup)\.php\??.*$/', '/', $redirect_to );
+                               $login_url = add_query_arg( 'redirect_to', $redirect_to, $login_url );
+                       }
+                       return $login_url;
+                       
+               }
+               
+               /**
+                * Get a safe redirect URL (ie: a wordpress.org-based one) from $_REQUEST['redirect_to'] or a safe alternative.
+                * 
+                * @return string Safe redirect URL from $_REQUEST['redirect_to']
+                */
+               protected function _get_safer_redirect_to() {
+                       // Setup a default redirect to URL, with a safe version toonly change if validation succeeds below.
+                       $redirect_to  = 'https://wordpress.org/';
+                       
+                       if ( ! empty( $_REQUEST['redirect_to'] ) ) {
+                               // User is requesting a further redirect afterward, let's make sure it's a legit target.
+                               $redirect_to_requested = function_exists( 'wp_sanitize_redirect' ) ? wp_sanitize_redirect( $_REQUEST['redirect_to'] ) : $_REQUEST['redirect_to'];
+                               if ( $this->_is_valid_targeted_domain( $redirect_to_requested ) ) {
+                                       $redirect_to = $redirect_to_requested;
+                               }
+                       } else {
+                               // Otherwise, attempt to guess the parent dir of where they came from and validate that.
+                               $redirect_to_source_parent = preg_replace( '/\/[^\/]+\.php\??.*$/', '/', "https://{$this->host}{$_SERVER['REQUEST_URI']}" );
+                               if ( $this->_is_valid_targeted_domain( $redirect_to_source_parent ) ) {
+                                       $redirect_to = $redirect_to_source_parent;
+                               }
+                       }
+                       
+                       return $redirect_to;
+               }
+               
+               /**
+                * Tests if the passed host/domain, or URL, is part of the WordPress.org domain.
+                * 
+                * @param unknown $string A domain, hostname, or URL
+                * @return boolean True is ok, false if not
+                */
+               protected function _is_valid_targeted_domain( $string ) {
+                       if ( empty( $string ) || ! is_string( $string ) ) {
+                               $string = '';
+                       }
+                       
+                       if ( strstr( $string , '/' ) ) {
+                               $url = parse_url( $string );
+                               $host = ( ! empty( $url['host'] ) ) ? $url['host'] : '';
+                       } else {
+                               $host = $string;
+                       }
+                       
+                       if ( ! empty( $host ) && strstr( $host , '.' ) ) {
+                               return ( preg_match( '/^(.+\.)?wordpress\.org$/', $host ) ) ? true : false;
+                       }
+                       
+                       return false;
+               }
+
+               /**
+                * Validates if target URL is within our bounds, then redirects to it if so, or to WP.org homepage (returns if headers already sent).
+                * 
+                * @param string $to Destination URL
+                * @param number $status HTTP redirect status, defaults to 302
+                * 
+                * @note: using our own over wp_safe_redirect(), etc, because not all targeted platforms (WP/BB/GP/etc) implement an equivalent, we run early, etc.
+                */
+               protected function _safe_redirect( $to, $status = 302 ) {
+                       if ( headers_sent() ) {
+                               return;
+                       }
+                       
+                       if ( ! $this->_is_valid_targeted_domain( $to ) ) {
+                               $to = $this->_get_safer_redirect_to();
+                       }
+                       
+                       header(
+                               'Location: ' . $to,
+                               true,
+                               preg_match( '/^30(1|2)$/', $status ) ? $status : 302
+                       );
+                       
+                       die();
+               }
+       }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/common/includes/wporg-sso/class-wporg-sso.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkcommonincludeswporgssogppluginphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/common/includes/wporg-sso/gp-plugin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/common/includes/wporg-sso/gp-plugin.php                               (rev 0)
+++ sites/trunk/common/includes/wporg-sso/gp-plugin.php 2015-11-20 17:35:17 UTC (rev 2098)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,67 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * WPORG SSO: filters gp_url_login() to return the equivalent SSO URL instead, removes the login route.
+ * 
+ * @uses WPOrg_SSO (class-wporg-sso.php) 
+ * @author stephdau
+ */
+if ( class_exists( 'GP_Plugin' ) && ! class_exists( 'GP_WPOrg_SSO' ) ) {
+       class GP_WPOrg_SSO extends GP_Plugin {
+               var $sso_obj;
+               
+               function __construct() {
+                       parent::__construct();
+                       // Load SSO lib
+                       $this->instantiate_sso();
+                       // Actions
+                       $this->add_action( 'init' );
+                       // Filters
+                       $this->add_filter( 'gp_url', array( 'args' => 3 ) );
+               }
+               
+               /**
+                * Instantiates a WPOrg_SSO (SSO lib) obj as self::sso_obj
+                */
+               function instantiate_sso() {
+                       if ( empty( $this->sso_obj ) ) {
+                               if ( ! class_exists( 'WPOrg_SSO' ) ) {
+                                       require_once __DIR__ . '/class-wporg-sso.php';
+                               }
+                               $this->sso_obj = new WPOrg_SSO();
+                       }
+               }
+               
+               /**
+                * Init action: remove the /login route, login URL filtered to SSO's in self::gp_url()
+                */
+               function init() {
+                       GP::$router->remove( '/login' );
+               }
+               
+               
+               /**
+                * Filter gp_url to return an equivalent login URL on the SSO instead of GP.
+                * 
+                * @param string $url
+                * @param string $path
+                * @param string $args
+                * @return string Login URL to SSO, with redirect_to back.
+                */
+               function gp_url( $url, $path, $args ) {
+                       if ( preg_match( '/^\/login(\?.+)?$/', $url ) ) {
+                               // If the URL is to the login route.
+                               if ( ! empty( $args['redirect_to'] ) ) {
+                                       // If there's already a redirect to request, pass it on to the SSO login.
+                                       $url = $this->sso_obj->login_url( null, $args['redirect_to'] );
+                               } else {
+                                       // Oherwise, make the current page the post-login target.
+                                       $url = $this->sso_obj->login_url( gp_url_current() );
+                               }
+                       }
+                       
+                       return $url;
+               }
+       }
+       
+       GP::$plugins->wporg_sso = new GP_WPOrg_SSO();
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/common/includes/wporg-sso/gp-plugin.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkcommonincludeswporgssowppluginphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/common/includes/wporg-sso/wp-plugin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/common/includes/wporg-sso/wp-plugin.php                               (rev 0)
+++ sites/trunk/common/includes/wporg-sso/wp-plugin.php 2015-11-20 17:35:17 UTC (rev 2098)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,78 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * WordPress-specific WPORG SSO: redirects all WP login and registration screens to our SSO ones.
+ * 
+ * @uses WPOrg_SSO (class-wporg-sso.php)
+ * @author stephdau
+ */
+if ( ! class_exists( 'WPOrg_SSO' ) ) {
+       require_once __DIR__ . '/class-wporg-sso.php';
+}
+
+if ( class_exists( 'WPOrg_SSO' ) && ! class_exists( 'WP_WPOrg_SSO' ) ) {
+       class WP_WPOrg_SSO extends WPOrg_SSO {
+               /**
+                * Constructor: add our action(s)/filter(s)
+                */
+               public function __construct() {
+                       parent::__construct();
+
+                       add_action( 'init', array( &$this, 'redirect_all_login_or_signup_to_sso' ) );
+               }
+       
+               /**
+                * Redirect all attempts to get to a WP login or signup to the SSO ones, or to a safe redirect location.
+                
+                * @example add_action( 'init', array( &$wporg_sso, 'redirect_all_wp_login_or_signup_to_sso' ) );
+                */
+               public function redirect_all_login_or_signup_to_sso() {
+                       if ( ! $this->_is_valid_targeted_domain( $this->host ) ) {
+                               // Not in list of targeted domains, not interested, bail out
+                               return;
+                       }
+                       
+                       $redirect_req = $this->_get_safer_redirect_to();
+                       
+                       // Add our host to the list of allowed ones.
+                       add_filter( 'allowed_redirect_hosts', array( &$this, 'add_allowed_redirect_host' ) );
+                       
+                       if ( preg_match( '/\/wp-signup\.php$/', $this->script ) ) {
+                               // If we're on any WP signup screen, redirect to the SSO host one,respecting the user's redirect_to request
+                               $this->_safe_redirect( add_query_arg( 'redirect_to', $redirect_req, $this->sso_signup_url ) );
+                       
+                       } else if ( self::SSO_HOST !== $this->host ) {
+                               // If we're not on the SSO host
+                               if ( preg_match( '/\/wp-login\.php$/', $this->script ) ) {
+                                       // If on a WP login screen...
+                                       $redirect_to_sso_login = $this->sso_login_url;
+                                       
+                                       // Pass thru the requested action, loggedout, if any
+                                       if ( ! empty( $_GET ) ) {
+                                               $redirect_to_sso_login = add_query_arg( $_GET, $redirect_to_sso_login );
+                                       }
+                                       
+                                       // Pay extra attention to the post-process redirect_to
+                                       $redirect_to_sso_login = add_query_arg( 'redirect_to', $redirect_req, $redirect_to_sso_login );
+                                       
+                                       // And actually redirect to the SSO login
+                                       $this->_safe_redirect( $redirect_to_sso_login );
+                               } else {
+                                       // Otherwise, filter the login_url to point to the SSO
+                                       add_action( 'login_url', array( &$this, 'login_url' ), 10, 2 );
+                               }
+                       } else if ( self::SSO_HOST === $this->host && ! preg_match( '/\/wp-login\.php$/', $this->script ) ) {
+                               // If on the SSO host, but not on its login or signup screen.
+                               // TODO: Relax rules when we want more  out of our theme then bypassing it altogether with redirects.
+                               if ( is_user_logged_in() ) {
+                                       // Mimic what happens after a login without a specified redirect.
+                                       $this->_safe_redirect( 'https://wordpress.org/support/profile/' . get_currentuserinfo()->user_login );
+                               } else {
+                                       // Otherwise, redirect to the login screen.
+                                       $this->_safe_redirect( $this->sso_login_url );
+                               }
+                       }
+               }
+       }
+       
+       new WP_WPOrg_SSO();
+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/common/includes/wporg-sso/wp-plugin.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>

</body>
</html>