@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.

can now tell phabricator you trust an auth provider's emails (useful for Google OAuth), which will mark emails as "verified" and will skip email verification.

Summary: This is useful when you're trying to onboard an entire office and you end up using the Google OAuth anyway.

Test Plan: tested locally. Maybe I should write some tests?

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9150

authored by

Tal Shiri and committed by
epriestley
43d45c49 cf6353e5

+67
+2
resources/sql/autopatches/20140515.trust-emails.sql
··· 1 + ALTER TABLE {$NAMESPACE}_auth.auth_providerconfig 2 + ADD `shouldTrustEmails` tinyint(1) NOT NULL DEFAULT 0 AFTER shouldAllowUnlink;
+5
src/applications/auth/controller/PhabricatorAuthRegisterController.php
··· 249 249 ($value_email === $default_email); 250 250 } 251 251 252 + if ($provider->shouldTrustEmails() && 253 + $value_email === $default_email) { 254 + $verify_email = true; 255 + } 256 + 252 257 $email_obj = id(new PhabricatorUserEmail()) 253 258 ->setAddress($value_email) 254 259 ->setIsVerified((int)$verify_email);
+23
src/applications/auth/controller/config/PhabricatorAuthEditController.php
··· 85 85 $v_registration = $config->getShouldAllowRegistration(); 86 86 $v_link = $config->getShouldAllowLink(); 87 87 $v_unlink = $config->getShouldAllowUnlink(); 88 + $v_trust_email = $config->getShouldTrustEmails(); 88 89 89 90 if ($request->isFormPost()) { 90 91 ··· 119 120 ->setTransactionType( 120 121 PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK) 121 122 ->setNewValue($request->getInt('allowUnlink', 0)); 123 + 124 + $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 125 + ->setTransactionType( 126 + PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS) 127 + ->setNewValue($request->getInt('trustEmails', 0)); 122 128 123 129 foreach ($properties as $key => $value) { 124 130 $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) ··· 212 218 'existing Phabricator accounts. If you disable this, Phabricator '. 213 219 'accounts will be permanently bound to provider accounts.')); 214 220 221 + $str_trusted_email = hsprintf( 222 + '<strong>%s:</strong> %s', 223 + pht('Trust Email Addresses'), 224 + pht( 225 + 'Phabricator will skip email verification for accounts registered '. 226 + 'through this provider.')); 227 + 215 228 $status_tag = id(new PHUITagView()) 216 229 ->setType(PHUITagView::TYPE_STATE); 217 230 if ($is_new) { ··· 261 274 1, 262 275 $str_unlink, 263 276 $v_unlink)); 277 + 278 + if ($provider->shouldAllowEmailTrustConfiguration()) { 279 + $form->appendChild( 280 + id(new AphrontFormCheckboxControl()) 281 + ->addCheckbox( 282 + 'trustEmails', 283 + 1, 284 + $str_trusted_email, 285 + $v_trust_email)); 286 + } 264 287 265 288 $provider->extendEditForm($request, $form, $properties, $issues); 266 289
+7
src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
··· 10 10 $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION; 11 11 $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_LINK; 12 12 $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK; 13 + $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS; 13 14 $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY; 14 15 15 16 return $types; ··· 32 33 return (int)$object->getShouldAllowLink(); 33 34 case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 34 35 return (int)$object->getShouldAllowUnlink(); 36 + case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 37 + return (int)$object->getShouldTrustEmails(); 35 38 case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY: 36 39 $key = $xaction->getMetadataValue( 37 40 PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY); ··· 48 51 case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 49 52 case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: 50 53 case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 54 + case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS: 51 55 case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY: 52 56 return $xaction->getNewValue(); 53 57 } ··· 66 70 return $object->setShouldAllowLink($v); 67 71 case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 68 72 return $object->setShouldAllowUnlink($v); 73 + case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS: 74 + return $object->setShouldTrustEmails($v); 69 75 case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY: 70 76 $key = $xaction->getMetadataValue( 71 77 PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY); ··· 89 95 case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 90 96 case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: 91 97 case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 98 + case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS: 92 99 // For these types, last transaction wins. 93 100 return $v; 94 101 }
+14
src/applications/auth/provider/PhabricatorAuthProvider.php
··· 141 141 return $this->getProviderConfig()->getShouldAllowUnlink(); 142 142 } 143 143 144 + public function shouldTrustEmails() { 145 + return $this->shouldAllowEmailTrustConfiguration() && 146 + $this->getProviderConfig()->getShouldTrustEmails(); 147 + } 148 + 149 + /** 150 + * Should we allow the adapter to be marked as "trusted" 151 + * This is true for all adapters except those that allow the user to type in 152 + * emails (@see PhabricatorAuthProviderPassword) 153 + */ 154 + public function shouldAllowEmailTrustConfiguration() { 155 + return true; 156 + } 157 + 144 158 public function buildLoginForm( 145 159 PhabricatorAuthStartController $controller) { 146 160 return $this->renderLoginForm($controller->getRequest(), $mode = 'start');
+3
src/applications/auth/provider/PhabricatorAuthProviderPassword.php
··· 350 350 return false; 351 351 } 352 352 353 + public function shouldAllowEmailTrustConfiguration() { 354 + return false; 355 + } 353 356 }
+1
src/applications/auth/storage/PhabricatorAuthProviderConfig.php
··· 12 12 protected $shouldAllowRegistration = 0; 13 13 protected $shouldAllowLink = 0; 14 14 protected $shouldAllowUnlink = 0; 15 + protected $shouldTrustEmails = 0; 15 16 16 17 protected $properties = array(); 17 18
+12
src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
··· 7 7 const TYPE_REGISTRATION = 'config:registration'; 8 8 const TYPE_LINK = 'config:link'; 9 9 const TYPE_UNLINK = 'config:unlink'; 10 + const TYPE_TRUST_EMAILS = "config:trustEmails"; 10 11 const TYPE_PROPERTY = 'config:property'; 11 12 12 13 const PROPERTY_KEY = 'auth:property'; ··· 118 119 } else { 119 120 return pht( 120 121 '%s disabled account unlinking.', 122 + $this->renderHandleLink($author_phid)); 123 + } 124 + break; 125 + case self::TYPE_TRUST_EMAILS: 126 + if ($new) { 127 + return pht( 128 + '%s enabled email trust.', 129 + $this->renderHandleLink($author_phid)); 130 + } else { 131 + return pht( 132 + '%s disabled email trust.', 121 133 $this->renderHandleLink($author_phid)); 122 134 } 123 135 break;