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