WordPress.com OAuth2 plugin
Summary: This plugin provides an OAuth authentication provider to authenticate users using WordPress.com Connect. This diff corresponds to github pull request https://github.com/facebook/phabricator/pull/593/ and had its libphutil counterpart reviewed in D9004. Test Plan: Configured WordPress.com as an authentication provider, saw it show up on the login screen, registered a new account, got expected defaults for my username/name/email/profile picture. Reviewers: chad, #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D9019
This commit is contained in:
		 Ashish SHUKLA
					Ashish SHUKLA
				
			
				
					committed by
					
						 epriestley
						epriestley
					
				
			
			
				
	
			
			
			 epriestley
						epriestley
					
				
			
						parent
						
							38739755c6
						
					
				
				
					commit
					0da22abdb5
				
			
							
								
								
									
										
											BIN
										
									
								
								resources/sprite/login_1x/WordPressCOM.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/sprite/login_1x/WordPressCOM.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.8 KiB | 
							
								
								
									
										
											BIN
										
									
								
								resources/sprite/login_2x/WordPressCOM.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/sprite/login_2x/WordPressCOM.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 2.8 KiB | 
| @@ -86,6 +86,11 @@ | |||||||
|       "rule" : ".login-Twitter", |       "rule" : ".login-Twitter", | ||||||
|       "hash" : "0b64983507a720b365474b778a966bab" |       "hash" : "0b64983507a720b365474b778a966bab" | ||||||
|     }, |     }, | ||||||
|  |     "login-WordPressCOM" : { | ||||||
|  |       "name" : "login-WordPressCOM", | ||||||
|  |       "rule" : ".login-WordPressCOM", | ||||||
|  |       "hash" : "c22a183bfb1e46deeab864223ec48db9" | ||||||
|  |     }, | ||||||
|     "login-Yahoo"        : { |     "login-Yahoo"        : { | ||||||
|       "name" : "login-Yahoo", |       "name" : "login-Yahoo", | ||||||
|       "rule" : ".login-Yahoo", |       "rule" : ".login-Yahoo", | ||||||
|   | |||||||
| @@ -1254,6 +1254,7 @@ phutil_register_library_map(array( | |||||||
|     'PhabricatorAuthProviderOAuthGitHub' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php', |     'PhabricatorAuthProviderOAuthGitHub' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php', | ||||||
|     'PhabricatorAuthProviderOAuthGoogle' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGoogle.php', |     'PhabricatorAuthProviderOAuthGoogle' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGoogle.php', | ||||||
|     'PhabricatorAuthProviderOAuthTwitch' => 'applications/auth/provider/PhabricatorAuthProviderOAuthTwitch.php', |     'PhabricatorAuthProviderOAuthTwitch' => 'applications/auth/provider/PhabricatorAuthProviderOAuthTwitch.php', | ||||||
|  |     'PhabricatorAuthProviderOAuthWordPress' => 'applications/auth/provider/PhabricatorAuthProviderOAuthWordPress.php', | ||||||
|     'PhabricatorAuthProviderPassword' => 'applications/auth/provider/PhabricatorAuthProviderPassword.php', |     'PhabricatorAuthProviderPassword' => 'applications/auth/provider/PhabricatorAuthProviderPassword.php', | ||||||
|     'PhabricatorAuthProviderPersona' => 'applications/auth/provider/PhabricatorAuthProviderPersona.php', |     'PhabricatorAuthProviderPersona' => 'applications/auth/provider/PhabricatorAuthProviderPersona.php', | ||||||
|     'PhabricatorAuthRegisterController' => 'applications/auth/controller/PhabricatorAuthRegisterController.php', |     'PhabricatorAuthRegisterController' => 'applications/auth/controller/PhabricatorAuthRegisterController.php', | ||||||
| @@ -4041,6 +4042,7 @@ phutil_register_library_map(array( | |||||||
|     'PhabricatorAuthProviderOAuthGitHub' => 'PhabricatorAuthProviderOAuth2', |     'PhabricatorAuthProviderOAuthGitHub' => 'PhabricatorAuthProviderOAuth2', | ||||||
|     'PhabricatorAuthProviderOAuthGoogle' => 'PhabricatorAuthProviderOAuth2', |     'PhabricatorAuthProviderOAuthGoogle' => 'PhabricatorAuthProviderOAuth2', | ||||||
|     'PhabricatorAuthProviderOAuthTwitch' => 'PhabricatorAuthProviderOAuth2', |     'PhabricatorAuthProviderOAuthTwitch' => 'PhabricatorAuthProviderOAuth2', | ||||||
|  |     'PhabricatorAuthProviderOAuthWordPress' => 'PhabricatorAuthProviderOAuth2', | ||||||
|     'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider', |     'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider', | ||||||
|     'PhabricatorAuthProviderPersona' => 'PhabricatorAuthProvider', |     'PhabricatorAuthProviderPersona' => 'PhabricatorAuthProvider', | ||||||
|     'PhabricatorAuthRegisterController' => 'PhabricatorAuthController', |     'PhabricatorAuthRegisterController' => 'PhabricatorAuthController', | ||||||
|   | |||||||
| @@ -0,0 +1,38 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | final class PhabricatorAuthProviderOAuthWordPress | ||||||
|  |   extends PhabricatorAuthProviderOAuth2 { | ||||||
|  |  | ||||||
|  |   public function getProviderName() { | ||||||
|  |     return pht('WordPress.com'); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   protected function getProviderConfigurationHelp() { | ||||||
|  |     $uri = PhabricatorEnv::getProductionURI('/'); | ||||||
|  |     $callback_uri = PhabricatorEnv::getURI($this->getLoginURI()); | ||||||
|  |  | ||||||
|  |     return pht( | ||||||
|  |       "To configure WordPress.com OAuth, create a new WordPress.com ". | ||||||
|  |       "Application here:\n\n". | ||||||
|  |       "https://developer.wordpress.com/apps/new/.". | ||||||
|  |       "\n\n". | ||||||
|  |       "You should use these settings in your application:". | ||||||
|  |       "\n\n". | ||||||
|  |       "  - **URL:** Set this to your full domain with protocol. For this ". | ||||||
|  |       "    Phabricator install, the correct value is: `%s`\n". | ||||||
|  |       "  - **Redirect URL**: Set this to: `%s`\n". | ||||||
|  |       "\n\n". | ||||||
|  |       "Once you've created an application, copy the **Client ID** and ". | ||||||
|  |       "**Client Secret** into the fields above.", | ||||||
|  |       $uri, | ||||||
|  |       $callback_uri); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   protected function newOAuthAdapter() { | ||||||
|  |     return new PhutilAuthAdapterOAuthWordPress(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   protected function getLoginIcon() { | ||||||
|  |     return 'WordPressCOM'; | ||||||
|  |   } | ||||||
|  | } | ||||||
| @@ -86,6 +86,10 @@ only screen and (-webkit-min-device-pixel-ratio: 1.5) { | |||||||
|   background-position: 0px -140px; |   background-position: 0px -140px; | ||||||
| } | } | ||||||
|  |  | ||||||
| .login-Yahoo { | .login-WordPressCOM { | ||||||
|   background-position: -35px -140px; |   background-position: -35px -140px; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .login-Yahoo { | ||||||
|  |   background-position: -70px -140px; | ||||||
|  | } | ||||||
|   | |||||||
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 105 KiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 34 KiB | 
		Reference in New Issue
	
	Block a user