@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+68 -7
+2
src/__phutil_library_map__.php
··· 818 818 'PhabricatorAuthLoginController' => 'applications/auth/controller/PhabricatorAuthLoginController.php', 819 819 'PhabricatorAuthProvider' => 'applications/auth/provider/PhabricatorAuthProvider.php', 820 820 'PhabricatorAuthProviderOAuth' => 'applications/auth/provider/PhabricatorAuthProviderOAuth.php', 821 + 'PhabricatorAuthProviderOAuthDisqus' => 'applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php', 821 822 'PhabricatorAuthProviderOAuthFacebook' => 'applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php', 822 823 'PhabricatorAuthProviderPassword' => 'applications/auth/provider/PhabricatorAuthProviderPassword.php', 823 824 'PhabricatorAuthRegisterController' => 'applications/auth/controller/PhabricatorAuthRegisterController.php', ··· 2678 2679 'PhabricatorAuthController' => 'PhabricatorController', 2679 2680 'PhabricatorAuthLoginController' => 'PhabricatorAuthController', 2680 2681 'PhabricatorAuthProviderOAuth' => 'PhabricatorAuthProvider', 2682 + 'PhabricatorAuthProviderOAuthDisqus' => 'PhabricatorAuthProviderOAuth', 2681 2683 'PhabricatorAuthProviderOAuthFacebook' => 'PhabricatorAuthProviderOAuth', 2682 2684 'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider', 2683 2685 'PhabricatorAuthRegisterController' => 'PhabricatorAuthController',
+7 -2
src/applications/auth/provider/PhabricatorAuthProvider.php
··· 54 54 55 55 abstract public function getProviderName(); 56 56 abstract public function getAdapter(); 57 - abstract public function isEnabled(); 57 + 58 + public function isEnabled() { 59 + // TODO: Remove once we switch to the new auth stuff. 60 + return false; 61 + } 62 + 58 63 abstract public function shouldAllowLogin(); 59 64 abstract public function shouldAllowRegistration(); 60 65 abstract public function shouldAllowAccountLink(); ··· 74 79 return; 75 80 } 76 81 77 - protected function willRegisterAccount(PhabricatorExternalAccount $account) { 82 + public function willRegisterAccount(PhabricatorExternalAccount $account) { 78 83 return; 79 84 } 80 85
+11 -3
src/applications/auth/provider/PhabricatorAuthProviderOAuth.php
··· 18 18 } 19 19 20 20 public function isEnabled() { 21 - return $this->getOAuthClientID() && $this->getOAuthClientSecret(); 21 + return parent::isEnabled() && 22 + $this->getOAuthClientID() && 23 + $this->getOAuthClientSecret(); 22 24 } 23 25 24 26 protected function configureAdapter(PhutilAuthAdapterOAuth $adapter) { 25 - $adapter->setClientID($this->getOAuthClientID()); 26 - $adapter->setClientSecret($this->getOAuthClientSecret()); 27 + if ($this->getOAuthClientID()) { 28 + $adapter->setClientID($this->getOAuthClientID()); 29 + } 30 + 31 + if ($this->getOAuthClientSecret()) { 32 + $adapter->setClientSecret($this->getOAuthClientSecret()); 33 + } 34 + 27 35 $adapter->setRedirectURI($this->getLoginURI()); 28 36 return $adapter; 29 37 }
+47
src/applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthProviderOAuthDisqus 4 + extends PhabricatorAuthProviderOAuth { 5 + 6 + public function getProviderName() { 7 + return pht('Disqus'); 8 + } 9 + 10 + protected function newOAuthAdapter() { 11 + return new PhutilAuthAdapterOAuthDisqus(); 12 + } 13 + 14 + public function isEnabled() { 15 + return parent::isEnabled() && 16 + PhabricatorEnv::getEnvConfig('disqus.auth-enabled'); 17 + } 18 + 19 + protected function getOAuthClientID() { 20 + return PhabricatorEnv::getEnvConfig('disqus.application-id'); 21 + } 22 + 23 + protected function getOAuthClientSecret() { 24 + $secret = PhabricatorEnv::getEnvConfig('disqus.application-secret'); 25 + if ($secret) { 26 + return new PhutilOpaqueEnvelope($secret); 27 + } 28 + return null; 29 + } 30 + 31 + public function shouldAllowLogin() { 32 + return true; 33 + } 34 + 35 + public function shouldAllowRegistration() { 36 + return PhabricatorEnv::getEnvConfig('disqus.registration-enabled'); 37 + } 38 + 39 + public function shouldAllowAccountLink() { 40 + return true; 41 + } 42 + 43 + public function shouldAllowAccountUnlink() { 44 + return !PhabricatorEnv::getEnvConfig('disqus.auth-permanent'); 45 + } 46 + 47 + }
+1 -2
src/applications/auth/provider/PhabricatorAuthProviderPassword.php
··· 10 10 } 11 11 12 12 public function isEnabled() { 13 - // TODO: Remove this once we switch to the new auth mechanism. 14 - return false && 13 + return parent::isEnabled() && 15 14 PhabricatorEnv::getEnvConfig('auth.password-auth-enabled'); 16 15 } 17 16