mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 07:11:04 +01:00
Add Disqus OAuth to new flows
Summary: Ref T1536. Adds Disqus as a Provider. Test Plan: Registered and logged in with Disqus. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1536 Differential Revision: https://secure.phabricator.com/D6165
This commit is contained in:
parent
1329b7b51e
commit
a12a6d5c7d
5 changed files with 68 additions and 7 deletions
|
@ -818,6 +818,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorAuthLoginController' => 'applications/auth/controller/PhabricatorAuthLoginController.php',
|
'PhabricatorAuthLoginController' => 'applications/auth/controller/PhabricatorAuthLoginController.php',
|
||||||
'PhabricatorAuthProvider' => 'applications/auth/provider/PhabricatorAuthProvider.php',
|
'PhabricatorAuthProvider' => 'applications/auth/provider/PhabricatorAuthProvider.php',
|
||||||
'PhabricatorAuthProviderOAuth' => 'applications/auth/provider/PhabricatorAuthProviderOAuth.php',
|
'PhabricatorAuthProviderOAuth' => 'applications/auth/provider/PhabricatorAuthProviderOAuth.php',
|
||||||
|
'PhabricatorAuthProviderOAuthDisqus' => 'applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php',
|
||||||
'PhabricatorAuthProviderOAuthFacebook' => 'applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php',
|
'PhabricatorAuthProviderOAuthFacebook' => 'applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.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',
|
||||||
|
@ -2678,6 +2679,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorAuthController' => 'PhabricatorController',
|
'PhabricatorAuthController' => 'PhabricatorController',
|
||||||
'PhabricatorAuthLoginController' => 'PhabricatorAuthController',
|
'PhabricatorAuthLoginController' => 'PhabricatorAuthController',
|
||||||
'PhabricatorAuthProviderOAuth' => 'PhabricatorAuthProvider',
|
'PhabricatorAuthProviderOAuth' => 'PhabricatorAuthProvider',
|
||||||
|
'PhabricatorAuthProviderOAuthDisqus' => 'PhabricatorAuthProviderOAuth',
|
||||||
'PhabricatorAuthProviderOAuthFacebook' => 'PhabricatorAuthProviderOAuth',
|
'PhabricatorAuthProviderOAuthFacebook' => 'PhabricatorAuthProviderOAuth',
|
||||||
'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider',
|
'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider',
|
||||||
'PhabricatorAuthRegisterController' => 'PhabricatorAuthController',
|
'PhabricatorAuthRegisterController' => 'PhabricatorAuthController',
|
||||||
|
|
|
@ -54,7 +54,12 @@ abstract class PhabricatorAuthProvider {
|
||||||
|
|
||||||
abstract public function getProviderName();
|
abstract public function getProviderName();
|
||||||
abstract public function getAdapter();
|
abstract public function getAdapter();
|
||||||
abstract public function isEnabled();
|
|
||||||
|
public function isEnabled() {
|
||||||
|
// TODO: Remove once we switch to the new auth stuff.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
abstract public function shouldAllowLogin();
|
abstract public function shouldAllowLogin();
|
||||||
abstract public function shouldAllowRegistration();
|
abstract public function shouldAllowRegistration();
|
||||||
abstract public function shouldAllowAccountLink();
|
abstract public function shouldAllowAccountLink();
|
||||||
|
@ -74,7 +79,7 @@ abstract class PhabricatorAuthProvider {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function willRegisterAccount(PhabricatorExternalAccount $account) {
|
public function willRegisterAccount(PhabricatorExternalAccount $account) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,20 @@ abstract class PhabricatorAuthProviderOAuth extends PhabricatorAuthProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isEnabled() {
|
public function isEnabled() {
|
||||||
return $this->getOAuthClientID() && $this->getOAuthClientSecret();
|
return parent::isEnabled() &&
|
||||||
|
$this->getOAuthClientID() &&
|
||||||
|
$this->getOAuthClientSecret();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configureAdapter(PhutilAuthAdapterOAuth $adapter) {
|
protected function configureAdapter(PhutilAuthAdapterOAuth $adapter) {
|
||||||
|
if ($this->getOAuthClientID()) {
|
||||||
$adapter->setClientID($this->getOAuthClientID());
|
$adapter->setClientID($this->getOAuthClientID());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->getOAuthClientSecret()) {
|
||||||
$adapter->setClientSecret($this->getOAuthClientSecret());
|
$adapter->setClientSecret($this->getOAuthClientSecret());
|
||||||
|
}
|
||||||
|
|
||||||
$adapter->setRedirectURI($this->getLoginURI());
|
$adapter->setRedirectURI($this->getLoginURI());
|
||||||
return $adapter;
|
return $adapter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorAuthProviderOAuthDisqus
|
||||||
|
extends PhabricatorAuthProviderOAuth {
|
||||||
|
|
||||||
|
public function getProviderName() {
|
||||||
|
return pht('Disqus');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newOAuthAdapter() {
|
||||||
|
return new PhutilAuthAdapterOAuthDisqus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isEnabled() {
|
||||||
|
return parent::isEnabled() &&
|
||||||
|
PhabricatorEnv::getEnvConfig('disqus.auth-enabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getOAuthClientID() {
|
||||||
|
return PhabricatorEnv::getEnvConfig('disqus.application-id');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getOAuthClientSecret() {
|
||||||
|
$secret = PhabricatorEnv::getEnvConfig('disqus.application-secret');
|
||||||
|
if ($secret) {
|
||||||
|
return new PhutilOpaqueEnvelope($secret);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldAllowLogin() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldAllowRegistration() {
|
||||||
|
return PhabricatorEnv::getEnvConfig('disqus.registration-enabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldAllowAccountLink() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldAllowAccountUnlink() {
|
||||||
|
return !PhabricatorEnv::getEnvConfig('disqus.auth-permanent');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,8 +10,7 @@ final class PhabricatorAuthProviderPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isEnabled() {
|
public function isEnabled() {
|
||||||
// TODO: Remove this once we switch to the new auth mechanism.
|
return parent::isEnabled() &&
|
||||||
return false &&
|
|
||||||
PhabricatorEnv::getEnvConfig('auth.password-auth-enabled');
|
PhabricatorEnv::getEnvConfig('auth.password-auth-enabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue