如何在 SVN 中设置访问控制?
我已经使用 SVN 设置了一个存储库并上传了项目。 有多个用户正在从事这些项目。 但是,并不是每个人都需要访问所有项目。 我想为每个项目设置用户权限。
我怎样才能实现这个目标?
I have set up a repository using SVN and uploaded projects. There are multiple users working on these projects. But, not everyone requires access to all projects. I want to set up user permissions for each project.
How can I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可以使用 svn+ssh:,然后它基于给定位置的存储库的访问控制。
这就是我在我的大学托管项目组存储库的方式,在那里我无法设置任何其他内容。 只需拥有一个该组拥有的目录,并在其中运行 svn-admin (或其他任何内容)就意味着我不需要进行任何配置。
You can use svn+ssh:, and then it's based on access control to the repository at the given location.
This is how I host a project group repository at my uni, where I can't set up anything else. Just having a directory that the group owns, and running svn-admin (or whatever it was) in there means that I didn't need to do any configuration.
@Stephen Bailey
为了完成您的答案,您还可以通过存储库中的纯文本文件将用户权限委托给项目经理。
为此,您需要使用包含以下内容的默认
authz
文件设置 SVN 数据库:此默认
authz
文件授权 SVN 管理员修改您的数据库中可见的纯文本文件。 SVN 存储库,名为'/admin/acl_descriptions.txt',SVN 管理员或项目经理将在其中修改和注册用户。然后,您设置一个预提交挂钩,它将检测修订是否由该文件(并且仅由该文件)组成。
如果是,此挂钩的脚本将验证纯文本文件的内容并检查每一行是否符合 SVN 语法。
然后,提交后挂钩将使用以下内容的串联更新
\conf\authz
文件:authz
文件/admin/acl_descriptions.txt
第一次迭代由 SVN 管理员完成,他补充道:
他提交了修改,并更新了
authz
文件。然后项目经理“zzzz”可以添加、删除或声明任何用户组以及他想要的任何用户。
他提交文件并更新 authz 文件。
这样,SVN 管理员就不必单独管理所有 SVN 存储库的任何和所有用户。
@Stephen Bailey
To complete your answer, you can also delegate the user rights to the project manager, through a plain text file in your repository.
To do that, you set up your SVN database with a default
authz
file containing the following:This default
authz
file authorizes the SVN administrators to modify a visible plain text file within your SVN repository, called '/admin/acl_descriptions.txt', in which the SVN administrators or project managers will modify and register the users.Then you set up a pre-commit hook which will detect if the revision is composed of that file (and only that file).
If it is, this hook's script will validate the content of your plain text file and check if each line is compliant with the SVN syntax.
Then a post-commit hook will update the
\conf\authz
file with the concatenation of:authz
file presented above/admin/acl_descriptions.txt
The first iteration is done by the SVN administrator, who adds:
He commits his modification, and that updates the
authz
file.Then the project manager 'zzzz' can add, remove or declare any group of users and any users he wants.
He commits the file and the
authz
file is updated.That way, the SVN administrator does not have to individually manage any and all users for all SVN repositories.
在您的 svn\repos\YourRepo\conf 文件夹中,您将找到两个文件:authz 和 passwd。 这是您需要调整的两个。
在 passwd 文件中,您需要添加一些用户名和密码。 我假设您已经这样做了,因为有人使用它:
然后您想使用 authz 文件相应地分配权限:
创建您想要的概念组,并向其中添加人员:
然后选择访问权限他们拥有权限和项目级别。
因此,让我们为我们的“所有访问”人员提供从根目录的所有访问权限:
但只为我们的“部分访问”人员提供对某些较低级别项目的只读访问权限:
您还可以在 authz 和 passwd 文件。
In your svn\repos\YourRepo\conf folder you will find two files, authz and passwd. These are the two you need to adjust.
In the passwd file you need to add some usernames and passwords. I assume you have already done this since you have people using it:
Then you want to assign permissions accordingly with the authz file:
Create the conceptual groups you want, and add people to it:
Then choose what access they have from both the permissions and project level.
So let's give our "all access" guys all access from the root:
But only give our "some access" guys read-only access to some lower level project:
You will also find some simple documentation in the authz and passwd files.
一个让我困惑的问题:
但是
你不需要在目录中包含尾部斜杠,否则你会看到 OPTIONS 请求的 403。
One gotcha which caught me out:
but
You need to not include a trailing slash on the directory, or you'll see 403 for the OPTIONS request.
Apache Subversion 支持基于路径的授权,可帮助您为用户配置精细权限以及存储库(文件或目录)中路径上的组帐户。 基于路径的授权支持三种访问级别 - 无访问、只读和读/写。
基于路径的授权权限使用特殊语法存储在每个存储库或每个服务器的授权文件中。 以下是 SVNBook 中的示例:
当您需要具有多个路径和帐户的复杂权限结构时,您可以受益于 VisualSVN Server 提供的基于 GUI 的权限管理工具:
VisualSVN 服务器管理器中的存储库权限
PowerShell 中的存储库权限
非管理员用户可以通过 RepoCfg 工具管理权限
Apache Subversion supports path-based authorization that helps you configure granular permissions for user and group accounts on paths in your repositories (files or directories). Path-based authorization supports three access levels - No Access, Read Only and Read / Write.
Path-based authorization permissions are stored in per-repository or per-server authorization files with a special syntax. Here is an example from SVNBook:
When you require a complex permission structure with many paths and accounts you can benefit from a GUI-based permission management tools provided by VisualSVN Server:
Repository permissions in VisualSVN Server Manager
Repository permissions in PowerShell
Non-admin users can manage permissions via the RepoCfg tool
最好的方法是设置 Apache 并通过它设置访问权限。 查看svn 书籍寻求帮助。 如果您不想使用 Apache,您还可以使用 svnserve 进行简约的访问控制。
The best way is to set up Apache and to set the access through it. Check the svn book for help. If you don't want to use Apache, you can also do minimalistic access control using svnserve.
虽然我建议 Apache 方法更好,但 SVN Serve 工作得很好并且非常简单。
假设您的存储库名为“my_repo”,并且存储在 C:\svn_repos 中:
在“C:\svn_repos\my_repo\conf”中创建一个名为“passwd”的文件。 该文件应如下所示:
<前><代码>[用户]
用户名=密码
约翰 = 约翰_密码
史蒂夫 = 史蒂夫_密码
在 C:\svn_repos\my_repo\conf\svnserve.conf 中设置:
<前><代码>[一般]
密码-db = passwd
授权访问=读取
验证访问=写入
这将强制用户登录才能读取或写入此存储库。
对每个存储库执行以下步骤,仅在每个存储库的
passwd
文件中包含适当的用户。Although I would suggest the Apache approach is better, SVN Serve works fine and is pretty straightforward.
Assuming your repository is called "my_repo", and it is stored in C:\svn_repos:
Create a file called "passwd" in "C:\svn_repos\my_repo\conf". This file should look like:
In C:\svn_repos\my_repo\conf\svnserve.conf set:
This will force users to log in to read or write to this repository.
Follow these steps for each repository, only including the appropriate users in the
passwd
file for each repository.