mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 07:12:41 +01:00
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:
parent
2bc44a130c
commit
70b30ab527
2 changed files with 49 additions and 0 deletions
|
@ -821,6 +821,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorAuthProviderOAuthDisqus' => 'applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php',
|
'PhabricatorAuthProviderOAuthDisqus' => 'applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php',
|
||||||
'PhabricatorAuthProviderOAuthFacebook' => 'applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php',
|
'PhabricatorAuthProviderOAuthFacebook' => 'applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php',
|
||||||
'PhabricatorAuthProviderOAuthGitHub' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php',
|
'PhabricatorAuthProviderOAuthGitHub' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php',
|
||||||
|
'PhabricatorAuthProviderOAuthGoogle' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGoogle.php',
|
||||||
'PhabricatorAuthProviderPassword' => 'applications/auth/provider/PhabricatorAuthProviderPassword.php',
|
'PhabricatorAuthProviderPassword' => 'applications/auth/provider/PhabricatorAuthProviderPassword.php',
|
||||||
'PhabricatorAuthRegisterController' => 'applications/auth/controller/PhabricatorAuthRegisterController.php',
|
'PhabricatorAuthRegisterController' => 'applications/auth/controller/PhabricatorAuthRegisterController.php',
|
||||||
'PhabricatorAuthStartController' => 'applications/auth/controller/PhabricatorAuthStartController.php',
|
'PhabricatorAuthStartController' => 'applications/auth/controller/PhabricatorAuthStartController.php',
|
||||||
|
@ -2683,6 +2684,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorAuthProviderOAuthDisqus' => 'PhabricatorAuthProviderOAuth',
|
'PhabricatorAuthProviderOAuthDisqus' => 'PhabricatorAuthProviderOAuth',
|
||||||
'PhabricatorAuthProviderOAuthFacebook' => 'PhabricatorAuthProviderOAuth',
|
'PhabricatorAuthProviderOAuthFacebook' => 'PhabricatorAuthProviderOAuth',
|
||||||
'PhabricatorAuthProviderOAuthGitHub' => 'PhabricatorAuthProviderOAuth',
|
'PhabricatorAuthProviderOAuthGitHub' => 'PhabricatorAuthProviderOAuth',
|
||||||
|
'PhabricatorAuthProviderOAuthGoogle' => 'PhabricatorAuthProviderOAuth',
|
||||||
'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider',
|
'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider',
|
||||||
'PhabricatorAuthRegisterController' => 'PhabricatorAuthController',
|
'PhabricatorAuthRegisterController' => 'PhabricatorAuthController',
|
||||||
'PhabricatorAuthStartController' => '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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue