Changeset 3166
- Timestamp:
- 05/18/2016 09:26:41 AM (9 years ago)
- Location:
- sites/trunk/common/includes/wporg-sso
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/common/includes/wporg-sso/bb-plugin.php
r2166 r3166 2 2 /** 3 3 * bbPress-specific WPORG SSO: redirects all BB login and registration screens to our SSO ones. 4 * 4 * 5 5 * @uses WPOrg_SSO (class-wporg-sso.php) 6 6 * @author stephdau … … 22 22 } 23 23 } 24 24 25 25 /** 26 26 * Redirect all attempts to get to a BB login or signup to the SSO ones, or to a safe redirect location. 27 * 27 * 28 28 * @example add_action( 'bb_init', array( &$wporg_sso, 'redirect_all_bb_login_or_signup_to_sso' ) ); 29 29 */ … … 45 45 return; 46 46 } 47 47 48 48 $redirect_to_sso_login = $this->sso_login_url; 49 49 50 50 // Pass thru the requested action, logged out, if any 51 51 if ( ! empty( $_GET ) ) { 52 52 $redirect_to_sso_login = add_query_arg( $_GET, $redirect_to_sso_login ); 53 53 } 54 54 55 55 // Pay extra attention to the post-process redirect_to 56 56 $redirect_to_sso_login = add_query_arg( 'redirect_to', urlencode( $this->_get_safer_redirect_to() ), $redirect_to_sso_login ); 57 57 58 58 // Redirect to SSO login, trying to pass on a decent redirect_to request. 59 59 $this->_safe_redirect( $redirect_to_sso_login ); … … 61 61 } 62 62 } 63 63 64 64 new BB_WPOrg_SSO(); 65 65 } -
sites/trunk/common/includes/wporg-sso/gp-plugin.php
r2150 r3166 2 2 /** 3 3 * WPORG SSO: filters gp_url_login() to return the equivalent SSO URL instead, removes the login route. 4 * 5 * @uses WPOrg_SSO (class-wporg-sso.php) 4 * 5 * @uses WPOrg_SSO (class-wporg-sso.php) 6 6 * @author stephdau 7 7 */ … … 9 9 class GP_WPOrg_SSO extends GP_Plugin { 10 10 var $sso_obj; 11 11 12 12 function __construct() { 13 13 parent::__construct(); 14 14 15 15 // Load SSO lib 16 16 $this->instantiate_sso(); 17 17 18 18 if ( $this->sso_obj->has_host() ) { 19 19 // Actions … … 23 23 } 24 24 } 25 25 26 26 /** 27 27 * Instantiates a WPOrg_SSO (SSO lib) obj as self::sso_obj … … 35 35 } 36 36 } 37 37 38 38 /** 39 39 * Init action: remove the /login route, login URL filtered to SSO's in self::gp_url() … … 42 42 GP::$router->remove( '/login' ); 43 43 } 44 45 44 45 46 46 /** 47 47 * Filter gp_url to return an equivalent login URL on the SSO instead of GP. 48 * 48 * 49 49 * @param string $url 50 50 * @param string $path … … 63 63 } 64 64 } 65 65 66 66 return $url; 67 67 } 68 68 } 69 69 70 70 GP::$plugins->wporg_sso = new GP_WPOrg_SSO(); 71 71 } -
sites/trunk/common/includes/wporg-sso/wp-plugin.php
r2465 r3166 2 2 /** 3 3 * WordPress-specific WPORG SSO: redirects all WP login and registration screens to our SSO ones. 4 * 4 * 5 5 * @uses WPOrg_SSO (class-wporg-sso.php) 6 6 * @author stephdau … … 23 23 'oauth' => '/oauth', 24 24 ); 25 25 26 26 /** 27 27 * Constructor: add our action(s)/filter(s) … … 36 36 } 37 37 } 38 38 39 39 /** 40 40 * Redirect all attempts to get to a WP login or signup to the SSO ones, or to a safe redirect location. 41 41 42 42 * @example add_action( 'init', array( &$wporg_sso, 'redirect_all_wp_login_or_signup_to_sso' ) ); 43 * 43 * 44 44 * @note Also handles accesses to lost password forms, since wp-login too. 45 45 */ … … 49 49 return; 50 50 } 51 51 52 52 $redirect_req = $this->_get_safer_redirect_to(); 53 53 54 54 // Add our host to the list of allowed ones. 55 55 add_filter( 'allowed_redirect_hosts', array( &$this, 'add_allowed_redirect_host' ) ); 56 56 57 57 // Replace the lost password URL by our own 58 58 add_filter( 'lostpassword_url', array( &$this, 'lostpassword_url' ), 10, 2 ); 59 59 60 60 if ( preg_match( '!/wp-signup\.php$!', $this->script ) ) { 61 61 // If we're on any WP signup screen, redirect to the SSO host one,respecting the user's redirect_to request 62 62 $this->_safe_redirect( add_query_arg( 'redirect_to', urlencode( $redirect_req ), $this->sso_signup_url ) ); 63 63 64 64 } elseif ( self::SSO_HOST !== $this->host ) { 65 65 // If we're not on the SSO host … … 67 67 // If on a WP login screen... 68 68 $redirect_to_sso_login = $this->sso_login_url; 69 69 70 70 // Pass thru the requested action, loggedout, if any 71 71 if ( ! empty( $_GET ) ) { 72 72 $redirect_to_sso_login = add_query_arg( $_GET, $redirect_to_sso_login ); 73 73 } 74 74 75 75 // Pay extra attention to the post-process redirect_to 76 76 $redirect_to_sso_login = add_query_arg( 'redirect_to', urlencode( $redirect_req ), $redirect_to_sso_login ); 77 77 78 78 // And actually redirect to the SSO login 79 79 $this->_safe_redirect( $redirect_to_sso_login ); 80 80 81 81 } else { 82 82 // Otherwise, filter the login_url to point to the SSO 83 83 add_action( 'login_url', array( &$this, 'login_url' ), 10, 2 ); 84 84 } 85 85 86 86 } else if ( self::SSO_HOST === $this->host ) { 87 87 // If on the SSO host … … 90 90 if ( preg_match( '!^(' . implode( '|', $this->valid_sso_paths ) . ')([/?]{1,2}.*)?$!', $_SERVER['REQUEST_URI'] ) ) { 91 91 // If we're on the path of interest 92 92 93 93 // Add a custom filter others can apply (theme, etc). 94 94 add_filter( 'is_valid_wporg_sso_path' , '__return_true' ); 95 95 96 96 if ( preg_match( '!^/(\?.*)?$!', $_SERVER['REQUEST_URI'] ) ) { 97 97 // If at host root (/) … … 133 133 } 134 134 } 135 135 136 136 /** 137 137 * Modifies the network_site_url on login.wordpress.org's login screen to make sure all forms and links 138 138 * go to the SSO host, not wordpress.org 139 * 139 * 140 140 * @param string $url 141 141 * @param string $path 142 142 * @param string $scheme 143 * @return string 144 * 143 * @return string 144 * 145 145 * @example add_action( 'network_site_url', array( &$this, 'login_network_site_url' ), 10, 3 ); 146 146 */ … … 149 149 $url = preg_replace( '!^(https?://)[^/]+(/.+)$!' , '\1'.self::SSO_HOST.'\2', $url ); 150 150 } 151 151 152 152 return $url; 153 153 } 154 154 155 155 156 156 /** 157 157 * Filters the defaults captions and options for the login form 158 * 158 * 159 159 * @param array $defaults 160 160 * @return array … … 168 168 return $defaults; 169 169 } 170 170 171 171 /** 172 172 * Filters the default lost password URL and returns our custom one instead. 173 * 173 * 174 174 * @param string $lostpassword_url 175 175 * @param string $redirect … … 178 178 return home_url( $this->valid_sso_paths['lostpassword'] . '/?redirect_to=' . $redirect ); 179 179 } 180 180 181 181 /** 182 182 * Redirects the user to her/his (support) profile. … … 194 194 } 195 195 } 196 196 197 197 new WP_WPOrg_SSO(); 198 198 }
Note: See TracChangeset
for help on using the changeset viewer.