SVN (Subversion) Access Control with Apache and mod_authz_svn

Setup SVN (Subversion) Access Control with Apache and mod_authz_svn
1. Change root user

su -
## OR ##
sudo -i

2. Add SVN (Subversion) users
Use following command:

## Create testuser ##
htpasswd -c -m /etc/svn-auth-users testuser
New password: 
Re-type new password: 
Adding password for user testuser

## Create testuser2 ##
htpasswd -m /etc/svn-auth-users testuser2
New password: 
Re-type new password: 
Adding password for user testuser2

Note: Use exactly same file and path name as used on subversion.conf file. This example use /etc/svn-auth-users file.
3. Create SVN Access Control file
On this guide, I use following /etc/svn-access-control file.

## Open /etc/svn-access-control file with your favourite editor ##
nano -w /etc/svn-access-control

Add following type content to file:

[groups]
testgroup = testuser1, testuser2
testgroup2 = testuser3, testuser4, testuser5
testgroup3 = testuser6, testuser7

[/]
* = r
@testgroup = rw
testuser4 = rw

[testrepo:/]
@testgroup2 = rw
testuser6 = rw

[testrepo2:/trunk]
@testgroup3 = rw
testuser5 = rw

[testrepo2:/tags]
@testgroup3 = r
testuser5 = rw

4. Add AuthzSVNAccessFile to subversion server config
Previously created /etc/httpd/conf.d/subversion.conf file:

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName "Subversion repositories"
   AuthUserFile /etc/svn-auth-users
   Require valid-user
</Location>

Add AuthzSVNAccessFile row to config:

AuthzSVNAccessFile /etc/svn-access-control

Finally /etc/httpd/conf.d/subversion.conf file should look something like following:

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName "Subversion repositories"
   AuthUserFile /etc/svn-auth-users
   AuthzSVNAccessFile /etc/svn-access-control
   Require valid-user
</Location>

5. Restart Apache Web Server

/etc/init.d/httpd restart
## OR ##
service httpd restart

Nhận xét

Bài đăng phổ biến