使用Apacheauthentication+授权来控制对Subversion子目录的访问

我有一个单独的SVN仓库/ var / svn /有几个子目录。 工作人员必须能够访问顶层目录及其中的所有子目录,但我想限制使用备用htpasswd文件访问子目录。

这适用于我们的工作人员。

<Location /> DAV svn SVNParentPath /var/svn AuthType Basic AuthBasicProvider ldap # mod_authnz_ldap AuthzLDAPAuthoritative off AuthLDAPURL "ldap.example.org:636/ou=people,ou=Unit,ou=Host,o=ldapsvc,dc=example,dc=org?uid?sub?(objectClass=PosixAccount)" AuthLDAPGroupAttribute memberUid AuthLDAPGroupAttributeIsDN off Require ldap-group cn=staff,ou=PosixGroup,ou=Unit,ou=Host,o=ldapsvc,dc=example,dc=org </Location> 

现在,我试图限制访问一个单独的htpasswd文件的子目录,如下所示:

 <Location /customerA> DAV svn SVNParentPath /var/svn # mod_authn_file AuthType Basic AuthBasicProvider file AuthUserFile /usr/local/etc/apache22/htpasswd.customerA Require user customerA </Location> 

我可以使用Firefox和curl来浏览到这个文件夹罚款:

 curl https://svn.example.org/customerA/ --user customerA:password 

但我不能使用检查这个SVN存储库:

 $ svn co https://svn.example.org/customerA/ svn: Repository moved permanently to 'https://svn.example.org/customerA/'; please relocate 

而在服务器日志上,我得到这个奇怪的错误:

 # httpd-access.log 192.168.19.13 - - [03/May/2010:16:40:00 -0700] "OPTIONS /customerA HTTP/1.1" 401 401 192.168.19.13 - customerA [03/May/2010:16:40:00 -0700] "OPTIONS /customerA HTTP/1.1" 301 244 # httpd-error.log [Mon May 03 16:40:00 2010] [error] [client 192.168.19.13] Could not fetch resource information. [301, #0] [Mon May 03 16:40:00 2010] [error] [client 192.168.19.13] Requests for a collection must have a trailing slash on the URI. [301, #0] 

我的问题:

  1. 我可以使用Apache访问控制来限制对Subversion子目录的访问吗? DocumentRoot被注释掉了,所以目前还不清楚http://subversion.apache.org/faq.html#http-301-error的常见问题。
  2. 我更喜欢不使用AuthzSVNAccessFile,因为它不支持LDAP组。 我们使用LDAP控制访问,并大量使用LDAP组。

我刚刚花了整整一个下午的时间来尝试去做,而且我想你问的问题1的答案是“不”。 如果我尝试它并查看错误日志,我会看到像“/ myrepo /!svn”这样的PROPFIND请求path上的错误:也就是说,我认为Subversion客户端有时正在请求仅对Subversion服务器模块有意义的魔术path,而不是像Apache可以理解和限制的“/ myrepo / subdir”这样的path。

但是,您使用SVNParentPath的事实让我怀疑/ var / svn实际上包含多个Subversion存储库,而customerA就是这样一个存储库。 您可以通过检查是否存在文件/ var / svn / customerA / format来进行判断。

那是对的吗? 如果是这样的话,你可以设置一个VirtualHost或者其他你可以使用SVNPath指令访问customerA仓库的位置。 例如:

 <VirtualHost> ServerName customerA.example.com <Location /> SVNPath /var/svn/customerA ... </Location> </VirtualHost>