##// END OF EJS Templates
svn-support: generate http downgrade only if we force_https in config.
marcink -
r1218:96294b6a default
parent child Browse files
Show More
@@ -27,6 +27,7 b' Once installed you need to enable ``dav_'
27
27
28 $ sudo a2enmod dav_svn
28 $ sudo a2enmod dav_svn
29 $ sudo a2enmod headers
29 $ sudo a2enmod headers
30 $ sudo a2enmod authn_anon
30
31
31
32
32 Configuring Apache Setup
33 Configuring Apache Setup
@@ -55,7 +56,7 b' permission issues could occur. To do thi'
55 export APACHE_RUN_GROUP=rhodecode
56 export APACHE_RUN_GROUP=rhodecode
56
57
57 1. To configure Apache, create and edit a virtual hosts file, for example
58 1. To configure Apache, create and edit a virtual hosts file, for example
58 :file:`/etc/apache2/sites-available/default.conf`. Below is an example
59 :file:`/etc/apache2/sites-enabled/default.conf`. Below is an example
59 how to use one with auto-generated config ```mod_dav_svn.conf```
60 how to use one with auto-generated config ```mod_dav_svn.conf```
60 from configured |RCE| instance.
61 from configured |RCE| instance.
61
62
@@ -16,7 +16,7 b''
16 # `Include` directive. See the following example snippet of a virtual host how
16 # `Include` directive. See the following example snippet of a virtual host how
17 # to include this configuration file.
17 # to include this configuration file.
18 #
18 #
19 # <VirtualHost *:8080>
19 # <VirtualHost *:8090>
20 # ServerAdmin webmaster@localhost
20 # ServerAdmin webmaster@localhost
21 # DocumentRoot /var/www/html
21 # DocumentRoot /var/www/html
22 # ErrorLog ${'${APACHE_LOG_DIR}'}/error.log
22 # ErrorLog ${'${APACHE_LOG_DIR}'}/error.log
@@ -38,7 +38,11 b''
38
38
39 # fix https -> http downgrade with DAV. It requires an header downgrade for
39 # fix https -> http downgrade with DAV. It requires an header downgrade for
40 # https -> http reverse proxy to work properly
40 # https -> http reverse proxy to work properly
41 % if use_https:
41 RequestHeader edit Destination ^https: http: early
42 RequestHeader edit Destination ^https: http: early
43 % else:
44 #RequestHeader edit Destination ^https: http: early
45 % endif
42
46
43 <Location "${location_root|n}">
47 <Location "${location_root|n}">
44 # The mod_dav_svn module takes the username from the apache request object.
48 # The mod_dav_svn module takes the username from the apache request object.
@@ -68,7 +68,8 b' class TestModDavSvnConfig(object):'
68 list_parent_path=True,
68 list_parent_path=True,
69 location_root=self.location_root,
69 location_root=self.location_root,
70 repo_groups=repo_groups,
70 repo_groups=repo_groups,
71 realm=self.realm
71 realm=self.realm,
72 use_ssl=True
72 )
73 )
73 # Assert that one location directive exists for each repository group.
74 # Assert that one location directive exists for each repository group.
74 for group in repo_groups:
75 for group in repo_groups:
@@ -79,13 +80,15 b' class TestModDavSvnConfig(object):'
79 self.assert_root_location_directive(generated_config)
80 self.assert_root_location_directive(generated_config)
80
81
81 @pytest.mark.parametrize('list_parent_path', [True, False])
82 @pytest.mark.parametrize('list_parent_path', [True, False])
82 def test_list_parent_path(self, list_parent_path):
83 @pytest.mark.parametrize('use_ssl', [True, False])
84 def test_list_parent_path(self, list_parent_path, use_ssl):
83 generated_config = utils._render_mod_dav_svn_config(
85 generated_config = utils._render_mod_dav_svn_config(
84 parent_path_root=self.parent_path_root,
86 parent_path_root=self.parent_path_root,
85 list_parent_path=list_parent_path,
87 list_parent_path=list_parent_path,
86 location_root=self.location_root,
88 location_root=self.location_root,
87 repo_groups=self.get_repo_group_mocks(count=10),
89 repo_groups=self.get_repo_group_mocks(count=10),
88 realm=self.realm
90 realm=self.realm,
91 use_ssl=use_ssl
89 )
92 )
90
93
91 # Assert that correct configuration directive is present.
94 # Assert that correct configuration directive is present.
@@ -95,3 +98,10 b' class TestModDavSvnConfig(object):'
95 else:
98 else:
96 assert re.search('SVNListParentPath\s+Off', generated_config)
99 assert re.search('SVNListParentPath\s+Off', generated_config)
97 assert not re.search('SVNListParentPath\s+On', generated_config)
100 assert not re.search('SVNListParentPath\s+On', generated_config)
101
102 if use_ssl:
103 assert 'RequestHeader edit Destination ^https: http: early' \
104 in generated_config
105 else:
106 assert '#RequestHeader edit Destination ^https: http: early' \
107 in generated_config
@@ -25,6 +25,7 b' from pyramid.renderers import render'
25
25
26 from rhodecode.events import trigger
26 from rhodecode.events import trigger
27 from rhodecode.lib.utils import get_rhodecode_realm, get_rhodecode_base_path
27 from rhodecode.lib.utils import get_rhodecode_realm, get_rhodecode_base_path
28 from rhodecode.lib.utils2 import str2bool
28 from rhodecode.model.db import RepoGroup
29 from rhodecode.model.db import RepoGroup
29
30
30 from . import config_keys
31 from . import config_keys
@@ -42,7 +43,10 b' def generate_mod_dav_svn_config(registry'
42 repositories organized in sub folders.
43 repositories organized in sub folders.
43 """
44 """
44 settings = registry.settings
45 settings = registry.settings
46 use_ssl = str2bool(registry.settings['force_https'])
47
45 config = _render_mod_dav_svn_config(
48 config = _render_mod_dav_svn_config(
49 use_ssl=use_ssl,
46 parent_path_root=get_rhodecode_base_path(),
50 parent_path_root=get_rhodecode_base_path(),
47 list_parent_path=settings[config_keys.list_parent_path],
51 list_parent_path=settings[config_keys.list_parent_path],
48 location_root=settings[config_keys.location_root],
52 location_root=settings[config_keys.location_root],
@@ -55,7 +59,8 b' def generate_mod_dav_svn_config(registry'
55
59
56
60
57 def _render_mod_dav_svn_config(
61 def _render_mod_dav_svn_config(
58 parent_path_root, list_parent_path, location_root, repo_groups, realm):
62 parent_path_root, list_parent_path, location_root, repo_groups, realm,
63 use_ssl):
59 """
64 """
60 Render mod_dav_svn configuration to string.
65 Render mod_dav_svn configuration to string.
61 """
66 """
@@ -72,6 +77,7 b' def _render_mod_dav_svn_config('
72 'repo_group_paths': repo_group_paths,
77 'repo_group_paths': repo_group_paths,
73 'svn_list_parent_path': list_parent_path,
78 'svn_list_parent_path': list_parent_path,
74 'rhodecode_realm': realm,
79 'rhodecode_realm': realm,
80 'use_https': use_ssl
75 }
81 }
76
82
77 # Render the configuration template to string.
83 # Render the configuration template to string.
@@ -162,13 +162,13 b''
162 </div>
162 </div>
163 <div class="input">
163 <div class="input">
164 ${h.text('vcs_svn_proxy_http_server_url',size=59)}
164 ${h.text('vcs_svn_proxy_http_server_url',size=59)}
165 % if c.svn_proxy_generate_config:
166 <span class="buttons">
167 <button class="btn btn-primary" id="vcs_svn_generate_cfg">${_('Generate Apache Config')}</button>
168 </span>
169 % endif
165 </div>
170 </div>
166 </div>
171 </div>
167 % if c.svn_proxy_generate_config:
168 <div class="buttons">
169 <button class="btn btn-primary" id="vcs_svn_generate_cfg">${_('Generate Apache Config')}</button>
170 </div>
171 % endif
172 </div>
172 </div>
173 </div>
173 </div>
174 % endif
174 % endif
General Comments 0
You need to be logged in to leave comments. Login now