From 65710ee2d24bb27f9effbe034f678e101058f56a Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 23 May 2012 12:37:43 -0700 Subject: [PATCH] Fix repository interactions for SVN repositories using the SVN protocol with SASL Summary: also makes the UI more general for this username + password business. Test Plan: - configure a phabricator repository from the svn server @asherwin provided which is configured for svn protocol with SASL - observed phabricator failing without my patch - upgraded my SVN client to support SASL (protip for mac users - http://www.wandisco.com/subversion/download#osx) - applied patch to phabricator - restarted daemons - noted daemon success - diffusion populating nicely Reviewers: epriestley Reviewed By: epriestley CC: aran, Koolvin Maniphest Tasks: T1260 Differential Revision: https://secure.phabricator.com/D2549 --- .../PhabricatorRepositoryEditController.php | 19 ++++++----- .../repository/PhabricatorRepository.php | 34 +++++++++++++++++++ 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php index 94e48e83b8..ae5cdfd0d6 100644 --- a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php +++ b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php @@ -231,7 +231,7 @@ final class PhabricatorRepositoryEditController $has_branches = ($is_git || $is_mercurial); $has_local = ($is_git || $is_mercurial); $has_branch_filter = ($is_git); - $has_http_support = $is_svn; + $has_auth_support = $is_svn; if ($request->isFormPost()) { $tracking = ($request->getStr('tracking') == 'enabled' ? true : false); @@ -442,8 +442,9 @@ final class PhabricatorRepositoryEditController 'Enter the Repository Root for this SVN repository. '. 'You can figure this out by running svn info and looking at '. 'the value in the Repository Root field. It should be a URI '. - 'and look like http://svn.example.org/svn/ or '. - 'svn+ssh://svn.example.com/svnroot/'; + 'and look like http://svn.example.org/svn/, '. + 'svn+ssh://svn.example.com/svnroot/, or '. + 'svn://svn.example.net/svn/'; $inset->appendChild( '

'.$instructions.'

'); $uri_label = 'Repository Root'; @@ -489,23 +490,25 @@ final class PhabricatorRepositoryEditController '...specify a path on disk where the daemon should '. 'look for a private key.')); - if ($has_http_support) { + if ($has_auth_support) { $inset ->appendChild( '
'. - 'If you want to connect to this repository over HTTP Basic Auth, '. + 'If you want to connect to this repository with a username and '. + 'password, such as over HTTP Basic Auth or SVN with SASL, '. 'enter the username and password to use. You can leave these '. - 'fields blank if the repository does not use HTTP Basic Auth.'. + 'fields blank if the repository does not use a username and '. + 'password for authentication.'. '
') ->appendChild( id(new AphrontFormTextControl()) ->setName('http-login') - ->setLabel('HTTP Basic Login') + ->setLabel('Username') ->setValue($repository->getDetail('http-login'))) ->appendChild( id(new AphrontFormPasswordControl()) ->setName('http-pass') - ->setLabel('HTTP Basic Password') + ->setLabel('Password') ->setValue($repository->getDetail('http-pass'))); } diff --git a/src/applications/repository/storage/repository/PhabricatorRepository.php b/src/applications/repository/storage/repository/PhabricatorRepository.php index d52ce559b9..7af5130d01 100644 --- a/src/applications/repository/storage/repository/PhabricatorRepository.php +++ b/src/applications/repository/storage/repository/PhabricatorRepository.php @@ -228,6 +228,25 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO { throw new Exception( "No support for HTTP Basic Auth in this version control system."); } + } else if ($this->shouldUseSVNProtocol()) { + switch ($this->getVersionControlSystem()) { + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: + $pattern = + "svn ". + "--non-interactive ". + "--no-auth-cache ". + "--username %s ". + "--password %s ". + $pattern; + array_unshift( + $args, + $this->getDetail('http-login'), + $this->getDetail('http-pass')); + break; + default: + throw new Exception( + "SVN protocol is SVN only."); + } } else { switch ($this->getVersionControlSystem()) { case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: @@ -320,6 +339,17 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO { } } + public function shouldUseSVNProtocol() { + $uri = new PhutilURI($this->getRemoteURI()); + $protocol = $uri->getProtocol(); + if ($this->isSVNProtocol($protocol)) { + return (bool)$this->getDetail('http-login'); + } else { + return false; + } + } + + public function getPublicRemoteURI() { $uri = new PhutilURI($this->getRemoteURI()); @@ -343,6 +373,10 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO { return ($protocol == 'http' || $protocol == 'https'); } + private function isSVNProtocol($protocol) { + return ($protocol == 'svn'); + } + public function isTracked() { return $this->getDetail('tracking-enabled', false); }