Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15431454
D11701.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D11701.id.diff
View Options
diff --git a/resources/sql/autopatches/20150205.authprovider.autologin.sql b/resources/sql/autopatches/20150205.authprovider.autologin.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20150205.authprovider.autologin.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_auth.auth_providerconfig
+ ADD shouldAutoLogin TINYINT(1) NOT NULL DEFAULT '0';
diff --git a/src/applications/auth/application/PhabricatorAuthApplication.php b/src/applications/auth/application/PhabricatorAuthApplication.php
--- a/src/applications/auth/application/PhabricatorAuthApplication.php
+++ b/src/applications/auth/application/PhabricatorAuthApplication.php
@@ -97,6 +97,7 @@
),
'login/(?P<pkey>[^/]+)/(?:(?P<extra>[^/]+)/)?'
=> 'PhabricatorAuthLoginController',
+ '(?P<loggedout>loggedout)/' => 'PhabricatorAuthStartController',
'register/(?:(?P<akey>[^/]+)/)?' => 'PhabricatorAuthRegisterController',
'start/' => 'PhabricatorAuthStartController',
'validate/' => 'PhabricatorAuthValidateController',
diff --git a/src/applications/auth/controller/PhabricatorAuthStartController.php b/src/applications/auth/controller/PhabricatorAuthStartController.php
--- a/src/applications/auth/controller/PhabricatorAuthStartController.php
+++ b/src/applications/auth/controller/PhabricatorAuthStartController.php
@@ -7,8 +7,7 @@
return false;
}
- public function processRequest() {
- $request = $this->getRequest();
+ public function handleRequest(AphrontRequest $request) {
$viewer = $request->getUser();
if ($viewer->isLoggedIn()) {
@@ -97,6 +96,19 @@
PhabricatorCookies::setClientIDCookie($request);
}
+ if (!$request->getURIData('loggedout') && count($providers) == 1) {
+ $auto_login_provider = head($providers);
+ $auto_login_config = $auto_login_provider->getProviderConfig();
+ if ($auto_login_provider instanceof PhabricatorPhabricatorAuthProvider &&
+ $auto_login_config->getShouldAutoLogin()) {
+ $auto_login_adapter = $provider->getAdapter();
+ $auto_login_adapter->setState($provider->getAuthCSRFCode($request));
+ return id(new AphrontRedirectResponse())
+ ->setIsExternal(true)
+ ->setURI($provider->getAdapter()->getAuthenticateURI());
+ }
+ }
+
$not_buttons = array();
$are_buttons = array();
$providers = msort($providers, 'getLoginOrder');
diff --git a/src/applications/auth/controller/PhabricatorLogoutController.php b/src/applications/auth/controller/PhabricatorLogoutController.php
--- a/src/applications/auth/controller/PhabricatorLogoutController.php
+++ b/src/applications/auth/controller/PhabricatorLogoutController.php
@@ -21,7 +21,7 @@
return true;
}
- public function processRequest() {
+ public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest();
$user = $request->getUser();
@@ -49,7 +49,7 @@
$request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
return id(new AphrontRedirectResponse())
- ->setURI('/login/');
+ ->setURI('/auth/loggedout/');
}
if ($user->getPHID()) {
diff --git a/src/applications/auth/controller/config/PhabricatorAuthEditController.php b/src/applications/auth/controller/config/PhabricatorAuthEditController.php
--- a/src/applications/auth/controller/config/PhabricatorAuthEditController.php
+++ b/src/applications/auth/controller/config/PhabricatorAuthEditController.php
@@ -83,6 +83,7 @@
$v_link = $config->getShouldAllowLink();
$v_unlink = $config->getShouldAllowUnlink();
$v_trust_email = $config->getShouldTrustEmails();
+ $v_auto_login = $config->getShouldAutoLogin();
if ($request->isFormPost()) {
@@ -123,6 +124,13 @@
PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS)
->setNewValue($request->getInt('trustEmails', 0));
+ if ($provider instanceof PhabricatorPhabricatorAuthProvider) {
+ $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
+ ->setTransactionType(
+ PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN)
+ ->setNewValue($request->getInt('autoLogin', 0));
+ }
+
foreach ($properties as $key => $value) {
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
->setTransactionType(
@@ -224,6 +232,12 @@
pht(
'Phabricator will skip email verification for accounts registered '.
'through this provider.'));
+ $str_auto_login = hsprintf(
+ '<strong>%s:</strong> %s',
+ pht('Allow Auto Login'),
+ pht(
+ 'Phabricator will automatically login with this provider if it is '.
+ 'the only available provider.'));
$status_tag = id(new PHUITagView())
->setType(PHUITagView::TYPE_STATE);
@@ -285,6 +299,16 @@
$v_trust_email));
}
+ if ($provider instanceof PhabricatorPhabricatorAuthProvider) {
+ $form->appendChild(
+ id(new AphrontFormCheckboxControl())
+ ->addCheckbox(
+ 'autoLogin',
+ 1,
+ $str_auto_login,
+ $v_auto_login));
+ }
+
$provider->extendEditForm($request, $form, $properties, $issues);
$form
diff --git a/src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php b/src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
--- a/src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
+++ b/src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
@@ -19,6 +19,7 @@
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_LINK;
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK;
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS;
+ $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN;
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY;
return $types;
@@ -43,6 +44,8 @@
return (int)$object->getShouldAllowUnlink();
case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
return (int)$object->getShouldTrustEmails();
+ case PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN:
+ return (int)$object->getShouldAutoLogin();
case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
$key = $xaction->getMetadataValue(
PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY);
@@ -60,6 +63,7 @@
case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
+ case PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN:
case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
return $xaction->getNewValue();
}
@@ -80,6 +84,8 @@
return $object->setShouldAllowUnlink($v);
case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
return $object->setShouldTrustEmails($v);
+ case PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN:
+ return $object->setShouldAutoLogin($v);
case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
$key = $xaction->getMetadataValue(
PhabricatorAuthProviderConfigTransaction::PROPERTY_KEY);
@@ -104,6 +110,7 @@
case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
case PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS:
+ case PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN:
// For these types, last transaction wins.
return $v;
}
diff --git a/src/applications/auth/provider/PhabricatorAuthProvider.php b/src/applications/auth/provider/PhabricatorAuthProvider.php
--- a/src/applications/auth/provider/PhabricatorAuthProvider.php
+++ b/src/applications/auth/provider/PhabricatorAuthProvider.php
@@ -449,7 +449,7 @@
return null;
}
- protected function getAuthCSRFCode(AphrontRequest $request) {
+ public function getAuthCSRFCode(AphrontRequest $request) {
$phcid = $request->getCookie(PhabricatorCookies::COOKIE_CLIENTID);
if (!strlen($phcid)) {
throw new Exception(
diff --git a/src/applications/auth/storage/PhabricatorAuthProviderConfig.php b/src/applications/auth/storage/PhabricatorAuthProviderConfig.php
--- a/src/applications/auth/storage/PhabricatorAuthProviderConfig.php
+++ b/src/applications/auth/storage/PhabricatorAuthProviderConfig.php
@@ -16,6 +16,7 @@
protected $shouldAllowLink = 0;
protected $shouldAllowUnlink = 0;
protected $shouldTrustEmails = 0;
+ protected $shouldAutoLogin = 0;
protected $properties = array();
@@ -42,6 +43,7 @@
'shouldAllowLink' => 'bool',
'shouldAllowUnlink' => 'bool',
'shouldTrustEmails' => 'bool',
+ 'shouldAutoLogin' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
'key_provider' => array(
diff --git a/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php b/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
--- a/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
+++ b/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
@@ -8,6 +8,7 @@
const TYPE_LINK = 'config:link';
const TYPE_UNLINK = 'config:unlink';
const TYPE_TRUST_EMAILS = 'config:trustEmails';
+ const TYPE_AUTO_LOGIN = 'config:autoLogin';
const TYPE_PROPERTY = 'config:property';
const PROPERTY_KEY = 'auth:property';
@@ -133,6 +134,17 @@
$this->renderHandleLink($author_phid));
}
break;
+ case self::TYPE_AUTO_LOGIN:
+ if ($new) {
+ return pht(
+ '%s enabled auto login.',
+ $this->renderHandleLink($author_phid));
+ } else {
+ return pht(
+ '%s disabled auto login.',
+ $this->renderHandleLink($author_phid));
+ }
+ break;
case self::TYPE_PROPERTY:
$provider = $this->getProvider();
if ($provider) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 25, 12:25 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7385729
Default Alt Text
D11701.id.diff (10 KB)
Attached To
Mode
D11701: Auth - allow for "auto login" providers
Attached
Detach File
Event Timeline
Log In to Comment