Debian 12 bookworm
Sponsored Link

Subversion : Access to Repositories via HTTP2023/07/21

 

Access to Repositories via HTTP, without running [svnserve].
This setting is not effective to the case you access via [svn://] or [file://].

[1]

Install Apache2, refer to here.

[2]

Configure SSL/TLS to Apache2, refer to here. (Optional for this setting)

[3] Install required packages.
root@dlp:~#
apt -y install libapache2-mod-svn
[4] Configure Apache2.
For example, Set HTTP access to [/var/svn/repos/project] repository.
root@dlp:~#
vi /etc/apache2/conf-available/subversion.conf
# create new

<Location /project>
    DAV svn
    AuthType Basic
    AuthName "DAV SVN"
    AuthUserFile /var/svn/.svnpasswd
    Require valid-user
    SVNPath /var/svn/repos/project
</Location> 

root@dlp:~#
a2enmod dav_svn

root@dlp:~#
a2enconf subversion

root@dlp:~#
chown -R www-data:www-data /var/svn/repos/project

root@dlp:~#
systemctl restart apache2

# add users

root@dlp:~#
htpasswd -c /var/svn/.svnpasswd debian

New password:
Re-type new password:
Adding password for user debian
[5] If also set access permission, Configure like follow.
root@dlp:~#
vi /var/svn/repos/project/conf/authzsvn.conf
# create new
# set group

[groups]
developer = debian,bookworm
operator = ubuntu
# everyone can [Read] access on root directory

[/]
* = r
# only [developer] group can [Read/Write] under the [trunk] directory

[project:/trunk]
@developer = rw
# only [operator] group can [Read/Write] under the [branches] directory

[project:/branches]
@operator = rw
# only [operator] group can [Read/Write] under the [tags] directory

[project:/tags]
@operator = rw
root@dlp:~#
vi /etc/apache2/conf-available/subversion.conf
<Location /project>
    DAV svn
    AuthType Basic
    AuthName "DAV SVN"
    AuthUserFile /var/svn/.svnpasswd
    Require valid-user
    SVNPath /var/svn/repos/project
    # add the line
    AuthzSVNAccessFile /var/svn/repos/project/conf/authzsvn.conf
</Location> 

root@dlp:~#
systemctl reload apache2

[6] Verify settings to access via HTTP/HTTPS from any Hosts.
bookworm@node01:~$
svn --username debian list https://dlp.srv.world/project

Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'debian': ********

branches/
tags/
trunk/

bookworm@node01:~$
echo 'store-plaintext-passwords = no' >> ~/.subversion/servers

bookworm@node01:~$
mkdir work

bookworm@node01:~$
cd work
bookworm@node01:~/work$
svn --username debian co https://dlp.srv.world/project

Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'debian': ********

A    project/branches
A    project/tags
A    project/trunk
A    project/trunk/index.html
Checked out revision 4.

bookworm@node01:~/work$
cd project/trunk
# after creating or editing any files under the repository,
# try to [commit] with [ubuntu] user

bookworm@node01:~/work/project/trunk$
echo index.html >> index.html

bookworm@node01:~/work/project/trunk$
svn --username ubuntu ci index.html -m "update by ubuntu"

Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'ubuntu': ********

Sending        index.html
Transmitting file data .svn: E195023: Commit failed (details follow):
svn: E195023: Changing file '/home/bookworm/work/project/trunk/index.html' is forbidden by the server
svn: E175013: While preparing '/home/bookworm/work/project/trunk/index.html' for commit
svn: E175013: Access to '/project/!svn/txr/5-5/trunk/index.html' forbidden
# denied normally as settings

# [commit] with [debian] user

bookworm@node01:~/work/project/trunk$
svn --username bookworm ci index.html -m "update by bookworm"

Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'bookworm': ********

Sending        index.html
Transmitting file data .done
Committing transaction...
Committed revision 5.
# done normally as settings
[7] It's also possible to access on Web browser (read only).
Matched Content