Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15380226
D7462.id16814.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D7462.id16814.diff
View Options
Index: resources/sql/patches/20131031.vcspassword.sql
===================================================================
--- /dev/null
+++ resources/sql/patches/20131031.vcspassword.sql
@@ -0,0 +1,10 @@
+CREATE TABLE {$NAMESPACE}_repository.repository_vcspassword
+(
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ repositoryPHID VARCHAR(64) NOT NULL COLLATE utf8_bin,
+ userPHID VARCHAR(64) NOT NULL COLLATE utf8_bin,
+ passwordHash VARCHAR(50) NOT NULL COLLATE utf8_bin,
+ dateCreated INT UNSIGNED NOT NULL,
+ dateModified INT UNSIGNED NOT NULL,
+ UNIQUE KEY `key_phid` (repositoryPHID, userPHID)
+);
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -534,6 +534,7 @@
'DiffusionSSHGitUploadPackWorkflow' => 'applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php',
'DiffusionSSHGitWorkflow' => 'applications/diffusion/ssh/DiffusionSSHGitWorkflow.php',
'DiffusionSSHWorkflow' => 'applications/diffusion/ssh/DiffusionSSHWorkflow.php',
+ 'DiffusionSetPasswordController' => 'applications/diffusion/controller/DiffusionSetPasswordController.php',
'DiffusionSetupException' => 'applications/diffusion/exception/DiffusionSetupException.php',
'DiffusionStableCommitNameQuery' => 'applications/diffusion/query/stablecommitname/DiffusionStableCommitNameQuery.php',
'DiffusionSvnCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionSvnCommitParentsQuery.php',
@@ -1672,6 +1673,7 @@
'PhabricatorRepositoryTransaction' => 'applications/repository/storage/PhabricatorRepositoryTransaction.php',
'PhabricatorRepositoryTransactionQuery' => 'applications/repository/query/PhabricatorRepositoryTransactionQuery.php',
'PhabricatorRepositoryType' => 'applications/repository/constants/PhabricatorRepositoryType.php',
+ 'PhabricatorRepositoryVCSPassword' => 'applications/repository/storage/PhabricatorRepositoryVCSPassword.php',
'PhabricatorS3FileStorageEngine' => 'applications/files/engine/PhabricatorS3FileStorageEngine.php',
'PhabricatorSQLPatchList' => 'infrastructure/storage/patch/PhabricatorSQLPatchList.php',
'PhabricatorSSHWorkflow' => 'infrastructure/ssh/PhabricatorSSHWorkflow.php',
@@ -2726,6 +2728,7 @@
'DiffusionSSHGitUploadPackWorkflow' => 'DiffusionSSHGitWorkflow',
'DiffusionSSHGitWorkflow' => 'DiffusionSSHWorkflow',
'DiffusionSSHWorkflow' => 'PhabricatorSSHWorkflow',
+ 'DiffusionSetPasswordController' => 'DiffusionController',
'DiffusionSetupException' => 'AphrontUsageException',
'DiffusionStableCommitNameQuery' => 'DiffusionQuery',
'DiffusionSvnCommitParentsQuery' => 'DiffusionCommitParentsQuery',
@@ -4011,6 +4014,7 @@
'PhabricatorRepositoryTestCase' => 'PhabricatorTestCase',
'PhabricatorRepositoryTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorRepositoryTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
+ 'PhabricatorRepositoryVCSPassword' => 'PhabricatorRepositoryDAO',
'PhabricatorS3FileStorageEngine' => 'PhabricatorFileStorageEngine',
'PhabricatorSSHWorkflow' => 'PhutilArgumentWorkflow',
'PhabricatorSavedQuery' =>
Index: src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
===================================================================
--- src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
+++ src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
@@ -78,6 +78,7 @@
'hosting/' => 'DiffusionRepositoryEditHostingController',
'(?P<serve>serve)/' => 'DiffusionRepositoryEditHostingController',
),
+ 'password/' => 'DiffusionSetPasswordController',
),
// NOTE: This must come after the rule above; it just gives us a
Index: src/applications/diffusion/controller/DiffusionRepositoryController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionRepositoryController.php
+++ src/applications/diffusion/controller/DiffusionRepositoryController.php
@@ -329,6 +329,8 @@
$view_uri = $this->getApplicationURI($repository->getCallsign().'/');
$edit_uri = $this->getApplicationURI($repository->getCallsign().'/edit/');
+ $password_uri =
+ $this->getApplicationURI($repository->getCallsign().'/password/');
$view = id(new PhabricatorActionListView())
->setUser($viewer)
@@ -348,6 +350,16 @@
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit));
+ if ($repository->isHosted() && $repository->getServeOverHTTP()) {
+ $view->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Set HTTP Access Password'))
+ ->setIcon('lock')
+ ->setHref($password_uri)
+ ->setWorkflow(!$viewer->isLoggedIn())
+ ->setDisabled(!$viewer->isLoggedIn()));
+ }
+
return $view;
}
Index: src/applications/diffusion/controller/DiffusionSetPasswordController.php
===================================================================
--- /dev/null
+++ src/applications/diffusion/controller/DiffusionSetPasswordController.php
@@ -0,0 +1,104 @@
+<?php
+
+final class DiffusionSetPasswordController
+ extends DiffusionController {
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $user = $request->getUser();
+ $drequest = $this->diffusionRequest;
+ $repository = $drequest->getRepository();
+
+ $repository = id(new PhabricatorRepositoryQuery())
+ ->setViewer($user)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->withIDs(array($repository->getID()))
+ ->executeOne();
+
+ if (!$repository) {
+ return new Aphront404Response();
+ }
+
+ $return_uri = $this->getRepositoryControllerURI($repository, '');
+
+ $vcspassword = id(new PhabricatorRepositoryVCSPassword())
+ ->loadOneWhere(
+ 'repositoryPHID = %s AND userPHID = %s',
+ $repository->getPHID(),
+ $user->getPHID());
+ if ($vcspassword === null) {
+ // Create new entry.
+ $vcspassword = id(new PhabricatorRepositoryVCSPassword());
+ $vcspassword->setRepositoryPHID($repository->getPHID());
+ $vcspassword->setUserPHID($user->getPHID());
+ }
+
+ $errors = array();
+
+ if ($request->isFormPost()) {
+ $newpassword = $request->getStr('password');
+
+ if (!$errors) {
+ $vcspassword->setPasswordHash(sha1($newpassword));
+ $vcspassword->save();
+
+ return id(new AphrontRedirectResponse())->setURI($return_uri);
+ }
+ }
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addCrumb(
+ id(new PhabricatorCrumbView())
+ ->setName(pht('Set Password')));
+
+ $title = pht('Edit %s', $repository->getName());
+
+ $error_view = null;
+ if ($errors) {
+ $error_view = id(new AphrontErrorView())
+ ->setTitle(pht('Form Errors'))
+ ->setErrors($errors);
+ }
+
+ $form = id(new AphrontFormView())
+ ->setUser($user)
+ ->appendRemarkupInstructions($this->getEncodingInstructions())
+ ->appendChild(
+ id(new AphrontFormTextControl())
+ ->setName('password')
+ ->setLabel(pht('HTTP Access Password')))
+ ->appendChild(
+ id(new AphrontFormSubmitControl())
+ ->setValue(pht('Change Password'))
+ ->addCancelButton($return_uri));
+
+ $object_box = id(new PHUIObjectBoxView())
+ ->setHeaderText($title)
+ ->setForm($form)
+ ->setFormError($error_view);
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $object_box,
+ ),
+ array(
+ 'title' => $title,
+ 'device' => true,
+ ));
+ }
+
+ private function getEncodingInstructions() {
+ return pht(<<<EOT
+To access this repository over HTTP, you must set a version control password.
+This password should not be the same as the password you use to login to your
+Phabricator account.
+EOT
+ );
+ }
+
+}
Index: src/applications/repository/storage/PhabricatorRepositoryVCSPassword.php
===================================================================
--- /dev/null
+++ src/applications/repository/storage/PhabricatorRepositoryVCSPassword.php
@@ -0,0 +1,10 @@
+<?php
+
+final class PhabricatorRepositoryVCSPassword extends PhabricatorRepositoryDAO {
+
+ protected $id;
+ protected $userPHID;
+ protected $repositoryPHID;
+ protected $passwordHash;
+
+}
Index: src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
===================================================================
--- src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
+++ src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
@@ -1712,6 +1712,10 @@
'type' => 'sql',
'name' => $this->getPatchPath('20131026.commitstatus.sql'),
),
+ '20131031.vcspassword.sql' => array(
+ 'type' => 'sql',
+ 'name' => $this->getPatchPath('20131031.vcspassword.sql'),
+ ),
);
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 15, 2:07 AM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7680308
Default Alt Text
D7462.id16814.diff (9 KB)
Attached To
Mode
D7462: Implementation of VCS passwords against user.
Attached
Detach File
Event Timeline
Log In to Comment