svn authz ldap同步工具
authzync的Python项目详细描述
______ __ __ ______ __ __ ______ __ __ __ __ ______ /\ __ \ /\ \/\ \ /\__ _\ /\ \_\ \ /\___ \ /\ \_\ \ /\ "-.\ \ /\ ___\ \ \ __ \ \ \ \_\ \ \/_/\ \/ \ \ __ \ \/_/ /__ \ \____ \ \ \ \-. \ \ \ \____ \ \_\ \_\ \ \_____\ \ \_\ \ \_\ \_\ /\_____\ \/\_____\ \ \_\\"\_\ \ \_____\ \/_/\/_/ \/_____/ \/_/ \/_/\/_/ \/_____/ \/_____/ \/_/ \/_/ \/_____/
- 支持LDAP和本地用户。
- 跟随嵌套组。
- 与Python2和3兼容。
安装
git
$ pypi install ldap3 $ git clone https://github.com/rbw0/authzync.git
pypi
$ pypi install authzync
用法示例
对authzync.json中指定的LDAP目录执行同步,从local_db.json获取非LDAP权限,并将结果写入svn_authz.txt
$ python authzync.py --config authzync.json --local_db local_db.json --authz svn_authz.txt
配置
authzync配置(–配置) 配置LDAP、映射、分析规则、日志记录等
本地用户(–本地数据库) 可用于为LDAP目录中不存在的用户(即本地用户)设置存储库权限。
工作原理
- authzync首先查找与ldap.base_dn中的patterns.access_pattern匹配的组
Note that there’s only one required part in the group name: ^{tt6}$ (RO or RW). This tells authzync which permission to apply to members of this group.
- 接下来,根据patterns.section_pattern
- 最后,获取成员列表并生成authz文件。
示例
authzync配置
Name | Value |
---|---|
ldap.base_dn | ou=SVN,dc=example,dc=com |
mappings.section_name | description |
patterns.access_pattern | ^svn_.*_(?P<repo_access>RO|RW)$ |
patterns.section_pattern | ^(?P<repo_name>.*):(?P<repo_path>/.*) |
…和…
ldap目录
Group name | ^{tt9}$ value | Members |
---|---|---|
svn_repo1-trunk_ro | repo1:/trunk | user1, user2 |
svn_repo2-branches_ro | repo2:/branches | user1, user3 |
svn_repo1_rw | repo1:/ | user3 |
将导致:
[repo1:/trunk] user1 = r user2 = r [repo2:/branches] user1 = r user3 = r [repo1:/] user3 = rw