Add Google support to new registration flow
Summary: Ref T1536. Adds Google support. Test Plan: Registered and logged in with Google. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1536 Differential Revision: https://secure.phabricator.com/D6167
This commit is contained in:
@@ -821,6 +821,7 @@ phutil_register_library_map(array(
|
||||
'PhabricatorAuthProviderOAuthDisqus' => 'applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php',
|
||||
'PhabricatorAuthProviderOAuthFacebook' => 'applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php',
|
||||
'PhabricatorAuthProviderOAuthGitHub' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php',
|
||||
'PhabricatorAuthProviderOAuthGoogle' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGoogle.php',
|
||||
'PhabricatorAuthProviderPassword' => 'applications/auth/provider/PhabricatorAuthProviderPassword.php',
|
||||
'PhabricatorAuthRegisterController' => 'applications/auth/controller/PhabricatorAuthRegisterController.php',
|
||||
'PhabricatorAuthStartController' => 'applications/auth/controller/PhabricatorAuthStartController.php',
|
||||
@@ -2683,6 +2684,7 @@ phutil_register_library_map(array(
|
||||
'PhabricatorAuthProviderOAuthDisqus' => 'PhabricatorAuthProviderOAuth',
|
||||
'PhabricatorAuthProviderOAuthFacebook' => 'PhabricatorAuthProviderOAuth',
|
||||
'PhabricatorAuthProviderOAuthGitHub' => 'PhabricatorAuthProviderOAuth',
|
||||
'PhabricatorAuthProviderOAuthGoogle' => 'PhabricatorAuthProviderOAuth',
|
||||
'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider',
|
||||
'PhabricatorAuthRegisterController' => 'PhabricatorAuthController',
|
||||
'PhabricatorAuthStartController' => 'PhabricatorAuthController',
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorAuthProviderOAuthGoogle
|
||||
extends PhabricatorAuthProviderOAuth {
|
||||
|
||||
public function getProviderName() {
|
||||
return pht('Google');
|
||||
}
|
||||
|
||||
protected function newOAuthAdapter() {
|
||||
return new PhutilAuthAdapterOAuthGoogle();
|
||||
}
|
||||
|
||||
public function isEnabled() {
|
||||
return parent::isEnabled() &&
|
||||
PhabricatorEnv::getEnvConfig('google.auth-enabled');
|
||||
}
|
||||
|
||||
protected function getOAuthClientID() {
|
||||
return PhabricatorEnv::getEnvConfig('google.application-id');
|
||||
}
|
||||
|
||||
protected function getOAuthClientSecret() {
|
||||
$secret = PhabricatorEnv::getEnvConfig('google.application-secret');
|
||||
if ($secret) {
|
||||
return new PhutilOpaqueEnvelope($secret);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function shouldAllowLogin() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shouldAllowRegistration() {
|
||||
return PhabricatorEnv::getEnvConfig('google.registration-enabled');
|
||||
}
|
||||
|
||||
public function shouldAllowAccountLink() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shouldAllowAccountUnlink() {
|
||||
return !PhabricatorEnv::getEnvConfig('google.auth-permanent');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user