Subversion权限控制手册

        在文章《Subversion详细说明》中,我们曾经建立了一个版本控制仓库,现在打开这个版本控制仓库,让我们来看看这个目录结构,

我们会在目录结构中找到一个叫做conf的文件夹,打开这个文件夹,你会看到三个文件,分别叫做authz,passwd,svnserve.conf。

下面我们就来介绍一下这三个文件的作用格式什么。
首先,我们介绍passwd这个文件。
用你习惯的文本编辑器打开这个文件,你会看到一些使用“#”注释掉的说明,其中关键的就是在[users]下面,有
# harry = harryssecret
# sally = sallyssecret
样的样板代码,意思就是有两个用户,其中一个的用户名叫“harry”,密码为“harryssecret”,而另一个用户名为“sally”,密码为“sallyssecret”。我们接下来为我们的测试下面添加一些用户,这样方便我们下面的说明。比如,我要添加三个用户,一个叫做“nicholas”,密码为“nicholas”,第二个用户名为“friend”,密码为“friend”,第三个为“stranger”,密码为“strangers”。
代码如下:
nicholas = nicholas
friend = friend
         stranger = stranger
这样,我们就添加好了三个认证用户。

 

### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
 
[users]
# harry = harryssecret
# sally = sallyssecret
nicholas = nicholas
friend = friend
stranger = stranger

 

 
       下面,我们来介绍authz这个文件,这个文件是控制权限的关键。
同样打开这个文件,你会看到一些注释掉的语句,
# [groups]
# [/foo/bar]
# [repository:/baz/fuz]
       下面,我们介绍一下用户组的概念。所谓用户组,顾名思义,就是一个成员组,一般情况下,在同一个成员组的人员享有同样的权力,比如读,写权。Subversion为我们提供了一个很好的用户组应用。
在之前,我们一共建立三个用户,nicholas,friend和stranger,我们现在设想一下我们的组情况,假设我们希望nicholas和friend在开发组中,这两个用户具有读和写的权力,而用户stranger在测试组中,只具备读的权力。那么我们该如何来控制这个权限呢?看看下面的代码:
我们先在[groups]标记下面,输入组的名称:
       dev_group = nicholas, friend
       test_group = stranger
到目前为止,我们已经为三个用户分好了用户组,其中nicholas和friend在dev_group中,而stranger则在test_group中。
下面,我们为两个组来分配权限。
首先我们要为这两个组所能访问的工程做一个规定,正如在之前的文章《 Eclipse 中使用Subversion 进行版本控制》中,曾经向版本参考提交了一个名为“TestSVNProj”的项目,下面我就假设刚刚建立的两个用户组都需要最这个工程进行操作。
我们在authz文件中,写下[TestSVNProj],这个是指定我们下面将对TestSVNProj项目进行定义。
我们使用如下代码:
@dev_group = rw
@test_group = r
这就定义了,对TestSVNProj项目,dev_group用户组可以进行读,写操作,而test_group用户组则只具备读的权限。
为了阻止其他用户组对这个文件有读的权力,我们可以再添加一句:
* =
这个语句就是指定其他的用户组的权力为空,也就是没有权力。

 

### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to a
### single user, to a group of users defined in a special [groups]
### section, or to anyone using the '*' wildcard. Each definition can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
 
[groups]
# harry_and_sally = harry,sally
 
dev_group = nicholas,friend
test_group = stranger
 
# [/foo/bar]
# harry = rw
# * =
 
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
 
[/TestSVNProj]
@dev_group = rw
@test_group = r
* =

 

 
最后,我们在来说说这个svnserve.conf文件,打开这个文件,我们就可以看出这个是Subversion权限配置的主文件,类似于读取相关信息的枢纽。
为了让我们刚刚配置的两个文件(passwd和authz)起作用,我们需要去掉password-db = passwd和authz-db = authz前面的注释符“#”,让Subversion知道要从上面两个文件中读取相关信息。
当然,你也可以指定其他的认证文件,写法如下:
        password-db = ../../passwd
authz-db = ../../authz
以此类推。
       在实战过程中,处于安全的考虑,我们往往要限制对匿名用户的访问权限,所以我们可以将anon-access = read前面的“#”去掉,并将read参数修改为none,表明禁止匿名用户对版本控制库的访问。

 

### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
 
### Visit http://subversion.tigris.org/ for more information.
 
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = none
# auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the conf
### directory. If you don't specify an authz-db, no path-based access
### control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
# realm = My First Repository

 

 
       至此,你可以控制你的项目,对其进行访问权限的控制了。
 
 
下面是我写的所有关于Subversion的文章,希望对大家有用,文章是按照内容的先后难度顺序排列,方便大家参考。
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值