mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Add GitHub auth to new flows
Summary: Ref T1536. Support for GitHub on new flows. Test Plan: Registered and logged in with GitHub. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1536 Differential Revision: https://secure.phabricator.com/D6166
This commit is contained in:
parent
a12a6d5c7d
commit
2bc44a130c
3 changed files with 50 additions and 5 deletions
|
@ -820,6 +820,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuthProviderOAuth' => 'applications/auth/provider/PhabricatorAuthProviderOAuth.php',
|
||||
'PhabricatorAuthProviderOAuthDisqus' => 'applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php',
|
||||
'PhabricatorAuthProviderOAuthFacebook' => 'applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php',
|
||||
'PhabricatorAuthProviderOAuthGitHub' => 'applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php',
|
||||
'PhabricatorAuthProviderPassword' => 'applications/auth/provider/PhabricatorAuthProviderPassword.php',
|
||||
'PhabricatorAuthRegisterController' => 'applications/auth/controller/PhabricatorAuthRegisterController.php',
|
||||
'PhabricatorAuthStartController' => 'applications/auth/controller/PhabricatorAuthStartController.php',
|
||||
|
@ -2681,6 +2682,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuthProviderOAuth' => 'PhabricatorAuthProvider',
|
||||
'PhabricatorAuthProviderOAuthDisqus' => 'PhabricatorAuthProviderOAuth',
|
||||
'PhabricatorAuthProviderOAuthFacebook' => 'PhabricatorAuthProviderOAuth',
|
||||
'PhabricatorAuthProviderOAuthGitHub' => 'PhabricatorAuthProviderOAuth',
|
||||
'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider',
|
||||
'PhabricatorAuthRegisterController' => 'PhabricatorAuthController',
|
||||
'PhabricatorAuthStartController' => 'PhabricatorAuthController',
|
||||
|
|
|
@ -12,11 +12,7 @@ final class PhabricatorAuthProviderOAuthFacebook
|
|||
}
|
||||
|
||||
public function isEnabled() {
|
||||
|
||||
// TODO: Remove this once we switch to the new auth mechanism.
|
||||
|
||||
return false &&
|
||||
parent::isEnabled() &&
|
||||
return parent::isEnabled() &&
|
||||
PhabricatorEnv::getEnvConfig('facebook.auth-enabled');
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorAuthProviderOAuthGitHub
|
||||
extends PhabricatorAuthProviderOAuth {
|
||||
|
||||
public function getProviderName() {
|
||||
return pht('GitHub');
|
||||
}
|
||||
|
||||
protected function newOAuthAdapter() {
|
||||
return new PhutilAuthAdapterOAuthGitHub();
|
||||
}
|
||||
|
||||
public function isEnabled() {
|
||||
return parent::isEnabled() &&
|
||||
PhabricatorEnv::getEnvConfig('github.auth-enabled');
|
||||
}
|
||||
|
||||
protected function getOAuthClientID() {
|
||||
return PhabricatorEnv::getEnvConfig('github.application-id');
|
||||
}
|
||||
|
||||
protected function getOAuthClientSecret() {
|
||||
$secret = PhabricatorEnv::getEnvConfig('github.application-secret');
|
||||
if ($secret) {
|
||||
return new PhutilOpaqueEnvelope($secret);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function shouldAllowLogin() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shouldAllowRegistration() {
|
||||
return PhabricatorEnv::getEnvConfig('github.registration-enabled');
|
||||
}
|
||||
|
||||
public function shouldAllowAccountLink() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shouldAllowAccountUnlink() {
|
||||
return !PhabricatorEnv::getEnvConfig('github.auth-permanent');
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue