Show More
@@ -1,65 +1,65 b'' | |||
|
1 | 1 | # Auto generated configuration for use with the Apache mod_dav_svn module. |
|
2 | 2 | # |
|
3 | 3 | # WARNING: Make sure your Apache instance which runs the mod_dav_svn module is |
|
4 | 4 | # only accessible by RhodeCode. Otherwise everyone is able to browse |
|
5 | 5 | # the repositories or run subversion operations (checkout/commit/etc.). |
|
6 | 6 | # |
|
7 | 7 | # The mod_dav_svn module does not support subversion repositories which are |
|
8 | 8 | # organized in subfolders. To support the repository groups of RhodeCode it is |
|
9 | 9 | # required to provide a <Location> block for each group pointing to the |
|
10 | 10 | # repository group sub folder. |
|
11 | 11 | # |
|
12 | 12 | # To ease the configuration RhodeCode auto generates this file whenever a |
|
13 | 13 | # repository group is created/changed/deleted. Auto generation can be configured |
|
14 | 14 | # in the ini file. |
|
15 | 15 | # |
|
16 | 16 | # To include this configuration into your apache config you can use the |
|
17 | 17 | # `Include` directive. See the following example snippet of a virtual host how |
|
18 | 18 | # to include this configuration file. |
|
19 | 19 | # |
|
20 | 20 | # <VirtualHost *:8080> |
|
21 | 21 | # ServerAdmin webmaster@localhost |
|
22 | 22 | # DocumentRoot /var/www/html |
|
23 | 23 | # ErrorLog ${'${APACHE_LOG_DIR}'}/error.log |
|
24 | 24 | # CustomLog ${'${APACHE_LOG_DIR}'}/access.log combined |
|
25 | 25 | # Include /path/to/generated/mod_dav_svn.conf |
|
26 | 26 | # </VirtualHost> |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | <Location ${location_root}> |
|
30 | 30 | # The mod_dav_svn module takes the username from the apache request object. |
|
31 | 31 | # Without authorization this will be empty and no username is logged for the |
|
32 | 32 | # transactions. This will result in "(no author)" for each revision. The |
|
33 | 33 | # following directives implement a fake authentication that allows every |
|
34 | 34 | # username/password combination. |
|
35 | 35 | AuthType Basic |
|
36 |
AuthName |
|
|
36 | AuthName ${rhodecode_realm} | |
|
37 | 37 | AuthBasicProvider anon |
|
38 | 38 | Anonymous * |
|
39 | 39 | Require valid-user |
|
40 | 40 | |
|
41 | 41 | DAV svn |
|
42 | 42 | SVNParentPath ${parent_path_root} |
|
43 | 43 | SVNListParentPath ${'On' if svn_list_parent_path else 'Off'} |
|
44 | 44 | |
|
45 | 45 | Allow from all |
|
46 | 46 | Order allow,deny |
|
47 | 47 | </Location> |
|
48 | 48 | |
|
49 | 49 | % for location, parent_path in repo_group_paths: |
|
50 | 50 | |
|
51 | 51 | <Location ${location}> |
|
52 | 52 | AuthType Basic |
|
53 |
AuthName |
|
|
53 | AuthName ${rhodecode_realm} | |
|
54 | 54 | AuthBasicProvider anon |
|
55 | 55 | Anonymous * |
|
56 | 56 | Require valid-user |
|
57 | 57 | |
|
58 | 58 | DAV svn |
|
59 | 59 | SVNParentPath ${parent_path} |
|
60 | 60 | SVNListParentPath ${'On' if svn_list_parent_path else 'Off'} |
|
61 | 61 | |
|
62 | 62 | Allow from all |
|
63 | 63 | Order allow,deny |
|
64 | 64 | </Location> |
|
65 | 65 | % endfor |
@@ -1,81 +1,83 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2016-2016 RhodeCode GmbH |
|
4 | 4 | # |
|
5 | 5 | # This program is free software: you can redistribute it and/or modify |
|
6 | 6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
7 | 7 | # (only), as published by the Free Software Foundation. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU Affero General Public License |
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 | # |
|
17 | 17 | # This program is dual-licensed. If you wish to learn more about the |
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | import logging |
|
22 | 22 | import os |
|
23 | 23 | |
|
24 | 24 | from pyramid.renderers import render |
|
25 | 25 | |
|
26 | from rhodecode.lib.utils import get_rhodecode_realm | |
|
26 | 27 | from rhodecode.model.db import RepoGroup |
|
27 | 28 | from . import config_keys |
|
28 | 29 | |
|
29 | 30 | |
|
30 | 31 | log = logging.getLogger(__name__) |
|
31 | 32 | |
|
32 | 33 | |
|
33 | 34 | def generate_mod_dav_svn_config(settings): |
|
34 | 35 | """ |
|
35 | 36 | Generate the configuration file for use with subversion's mod_dav_svn |
|
36 | 37 | module. The configuration has to contain a <Location> block for each |
|
37 | 38 | available repository group because the mod_dav_svn module does not support |
|
38 | 39 | repositories organized in sub folders. |
|
39 | 40 | """ |
|
40 | 41 | config = _render_mod_dav_svn_config( |
|
41 | 42 | settings[config_keys.parent_path_root], |
|
42 | 43 | settings[config_keys.list_parent_path], |
|
43 | 44 | settings[config_keys.location_root], |
|
44 | 45 | RepoGroup.get_all_repo_groups()) |
|
45 | 46 | _write_mod_dav_svn_config(config, settings[config_keys.config_file_path]) |
|
46 | 47 | |
|
47 | 48 | |
|
48 | 49 | def _render_mod_dav_svn_config( |
|
49 | 50 | parent_path_root, list_parent_path, location_root, repo_groups): |
|
50 | 51 | """ |
|
51 | 52 | Render mod_dav_svn configuration to string. |
|
52 | 53 | """ |
|
53 | 54 | repo_group_paths = [] |
|
54 | 55 | for repo_group in repo_groups: |
|
55 | 56 | group_path = repo_group.full_path_splitted |
|
56 | 57 | location = os.path.join(location_root, *group_path) |
|
57 | 58 | parent_path = os.path.join(parent_path_root, *group_path) |
|
58 | 59 | repo_group_paths.append((location, parent_path)) |
|
59 | 60 | |
|
60 | 61 | context = { |
|
61 | 62 | 'location_root': location_root, |
|
62 | 63 | 'parent_path_root': parent_path_root, |
|
63 | 64 | 'repo_group_paths': repo_group_paths, |
|
64 | 65 | 'svn_list_parent_path': list_parent_path, |
|
66 | 'rhodecode_realm': get_rhodecode_realm(), | |
|
65 | 67 | } |
|
66 | 68 | |
|
67 | 69 | # Render the configuration template to string. |
|
68 | 70 | template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako' |
|
69 | 71 | return render(template, context) |
|
70 | 72 | |
|
71 | 73 | |
|
72 | 74 | def _write_mod_dav_svn_config(config, filepath): |
|
73 | 75 | """ |
|
74 | 76 | Write mod_dav_svn config to file. Log on exceptions but do not raise. |
|
75 | 77 | """ |
|
76 | 78 | try: |
|
77 | 79 | with open(filepath, 'w') as file_: |
|
78 | 80 | file_.write(config) |
|
79 | 81 | except Exception: |
|
80 | 82 | log.exception( |
|
81 | 83 | 'Can not write mod_dav_svn configuration to "%s"', filepath) |
General Comments 0
You need to be logged in to leave comments.
Login now