如何在 SVN 中设置访问控制?

发布于 2024-07-05 23:15:12 字数 111 浏览 8 评论 0原文

我已经使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

瞳孔里扚悲伤 2024-07-12 23:15:12

您可以使用 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.

不如归去 2024-07-12 23:15:12

@Stephen Bailey

为了完成您的答案,您还可以通过存储库中的纯文本文件将用户权限委托给项目经理。

为此,您需要使用包含以下内容的默认 authz 文件设置 SVN 数据库:

###########################################################################
# The content of this file always precedes the content of the
# $REPOS/admin/acl_descriptions.txt file.
# It describes the immutable permissions on main folders.
###########################################################################
[groups]
svnadmins = xxx,yyy,....

[/]
@svnadmins = rw
* = r
[/admin]
@svnadmins = rw
@projadmins = r
* =

[/admin/acl_descriptions.txt]
@projadmins = rw

此默认 authz 文件授权 SVN 管理员修改您的数据库中可见的纯文本文件。 SVN 存储库,名为'/admin/acl_descriptions.txt',SVN 管理员或项目经理将在其中修改和注册用户。

然后,您设置一个预提交挂钩,它将检测修订是否由该文件(并且仅由该文件)组成。

如果是,此挂钩的脚本将验证纯文本文件的内容并检查每一行是否符合 SVN 语法。

然后,提交后挂钩将使用以下内容的串联更新 \conf\authz 文件:

  • 上方显示的 TEMPLATE authz 文件
  • 纯文本文件 /admin/acl_descriptions.txt

第一次迭代由 SVN 管理员完成,他补充道:

[groups]
projadmins = zzzz

他提交了修改,并更新了 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:

###########################################################################
# The content of this file always precedes the content of the
# $REPOS/admin/acl_descriptions.txt file.
# It describes the immutable permissions on main folders.
###########################################################################
[groups]
svnadmins = xxx,yyy,....

[/]
@svnadmins = rw
* = r
[/admin]
@svnadmins = rw
@projadmins = r
* =

[/admin/acl_descriptions.txt]
@projadmins = rw

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:

  • the TEMPLATE authz file presented above
  • the plain text file /admin/acl_descriptions.txt

The first iteration is done by the SVN administrator, who adds:

[groups]
projadmins = zzzz

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.

漫漫岁月 2024-07-12 23:15:12

在您的 svn\repos\YourRepo\conf 文件夹中,您将找到两个文件:authzpasswd。 这是您需要调整的两个。

passwd 文件中,您需要添加一些用户名和密码。 我假设您已经这样做了,因为有人使用它:

[users]
User1=password1
User2=password2

然后您想使用 authz 文件相应地分配权限:

创建您想要的概念组,并向其中添加人员:

[groups]
allaccess = user1
someaccess = user2

然后选择访问权限他们拥有权限和项目级别。

因此,让我们为我们的“所有访问”人员提供从根目录的所有访问权限:

[/]
@allaccess = rw

但只为我们的“部分访问”人员提供对某些较低级别项目的只读访问权限:

[/someproject]
@someaccess = r

您还可以在 authzpasswd 文件。

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:

[users]
User1=password1
User2=password2

Then you want to assign permissions accordingly with the authz file:

Create the conceptual groups you want, and add people to it:

[groups]
allaccess = user1
someaccess = user2

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:

[/]
@allaccess = rw

But only give our "some access" guys read-only access to some lower level project:

[/someproject]
@someaccess = r

You will also find some simple documentation in the authz and passwd files.

夜清冷一曲。 2024-07-12 23:15:12

一个让我困惑的问题:

[repos:/path/to/dir/] # this won't work

但是

[repos:/path/to/dir]  # this is right

你不需要在目录中包含尾部斜杠,否则你会看到 OPTIONS 请求的 403。

One gotcha which caught me out:

[repos:/path/to/dir/] # this won't work

but

[repos:/path/to/dir]  # this is right

You need to not include a trailing slash on the directory, or you'll see 403 for the OPTIONS request.

终陌 2024-07-12 23:15:12

Apache Subversion 支持基于路径的授权,可帮助您为用户配置精细权限以及存储库(文件或目录)中路径上的组帐户。 基于路径的授权支持三种访问级别 - 无访问、只读和读/写。

基于路径的授权权限使用特殊语法存储在每个存储库或每个服务器的授权文件中。 以下是 SVNBook 中的示例:

[calc:/branches/calc/bug-142]
harry = rw
sally = r

当您需要具有多个路径和帐户的复杂权限结构时,您可以受益于 VisualSVN Server 提供的基于 GUI 的权限管理工具:

  • 服务器管理员可以通过 VisualSVN Server Manager 控制台或PowerShell,
  • 非管理员用户可以通过RepoCfg管理权限。

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:

[calc:/branches/calc/bug-142]
harry = rw
sally = r

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:

  • Server administrators can manage user and group permissions via the VisualSVN Server Manager console or PowerShell,
  • Non-admin users can manage permissions via RepoCfg.

Repository permissions in VisualSVN Server Manager
enter image description here

Repository permissions in PowerShell
enter image description here

Non-admin users can manage permissions via the RepoCfg tool
enter image description here

冰火雁神 2024-07-12 23:15:12

最好的方法是设置 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.

陌路终见情 2024-07-12 23:15:12

虽然我建议 Apache 方法更好,但 SVN Serve 工作得很好并且非常简单。

假设您的存储库名为“my_repo”,并且存储在 C:\svn_repos 中:

  1. 在“C:\svn_repos\my_repo\conf”中创建一个名为“passwd”的文件。 该文件应如下所示:

    <前><代码>[用户]
    用户名=密码
    约翰 = 约翰_密码
    史蒂夫 = 史蒂夫_密码

  2. 在 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:

  1. Create a file called "passwd" in "C:\svn_repos\my_repo\conf". This file should look like:

    [Users]
    username = password
    john = johns_password
    steve = steves_password
    
  2. In C:\svn_repos\my_repo\conf\svnserve.conf set:

    [general]
    password-db = passwd
    auth-access=read
    auth-access=write
    

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文