Ubuntu 22.04
Sponsored Link

Subversion : Access to Repositories via HTTP2022/09/27

 
Access to Repositories via HTTP, without running [svnserve].
This setting is not effective to the case you access via [svn://] or [file://].
[1]
[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. /var/svn/repos/project

root@dlp:~#
systemctl restart apache2

# add users

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

New password:
Re-type new password:
Adding password for user ubuntu
[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 = ubuntu,debian
operator = jammy
# 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.
jammy@node01:~$
svn --username ubuntu list https://dlp.srv.world/project

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

branches/
tags/
trunk/

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

jammy@node01:~$
mkdir work

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

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

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

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

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

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

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

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

# [commit] with [debian] user

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

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

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