Subversion - 使用 SVNParentPath 时如何控制用户对单个存储库的访问?

问题描述:

我有 Subversion 存储库,可以正常工作,所有用户都需要密码身份验证.我的配置发布在下面.如何修改此配置,以便允许单个用户对我的存储库之一进行只读访问?

I have subversion repositories that are working fine with password authentication required for all users. My config is posted below. How do I go about modifying this configuration so that I can allow a single user to have read-only access to one of my repositories?

提供的示例需要使用 SVNParentPath 而不是 SVNPath.前者允许您指定包含多个 subversion 存储库的目录.

The example provided needs to work with SVNParentPath not SVNPath. The former allows you to specify a directory containing multiple subversion repositories.

<VirtualHost *:80>
    ServerAdmin apache@mycompany.org
    DocumentRoot "d:/Apache2/htdocs/"
    ServerName code.mycompany.org
    ErrorLog "logs/src.mycompany.org-error.log"
    CustomLog "logs/src.mycompany.org-access.log" common
    SetOutputFilter DEFLATE

    <Location />
      DAV svn
      SVNParentPath D:\SVN
      AuthType Basic
      AuthName "My Repository"
      AuthUserFile conf/myteam.pwd
      Require valid-user
    </Location>   
</VirtualHost>

我自己使用 SVN Book 解决了这个问题.

I've worked this out myself using the SVN Book.

首先,确保您在 AuthUserFile 中设置了一些用户.接下来,为授权规则创建一个文件 (conf/myteam.authz).像这样填充这个文件.

First, make sure you have some users setup in the AuthUserFile. Next, create a file for the authorization rules (conf/myteam.authz). Populate this file like this.

[groups]
my-developers = BrianLy
external-developers = JamesKL

[/]
@my-developers = rw

[repository-name-here:/path/here]
@external-developers = r

这会创建 2 个组,然后为这些组分配权限.我的团队拥有对所有存储库的开发人员访问权限.第二条规则指定第二组对特定存储库的访问权限有限.

This creates 2 groups which are then assigned rights. My team has developer access to all repositories. The second rule specifies that the second group has limited access to a specific repository.

然后通过在 AuthUserFile 下面添加这一行来更新您的 Apache 配置

Then update your Apache configuration by adding this line below AuthUserFile

AuthzSVNAccessFile conf/myteam.authz

重新启动Apache(必需)

Re-start Apache (required)