##// END OF EJS Templates
updated with a latest changes.
ilin.s -
r5536:2c8dbdc5 merge default
parent child Browse files
Show More
@@ -0,0 +1,17 b''
1
2 def apply_license(*args, **kwargs):
3 pass
4
5 try:
6 from rc_license.models import apply_license
7 except ImportError:
8 pass
9
10
11 def apply_license_from_file(*args, **kwargs):
12 pass
13
14 try:
15 from rc_license.models import apply_license_from_file
16 except ImportError:
17 pass
@@ -33,7 +33,7 b' channelstream==0.7.1'
33 gevent==24.2.1
33 gevent==24.2.1
34 greenlet==3.0.3
34 greenlet==3.0.3
35 zope.event==5.0.0
35 zope.event==5.0.0
36 zope.interface==6.4.post2
36 zope.interface==7.0.3
37 itsdangerous==1.1.0
37 itsdangerous==1.1.0
38 marshmallow==2.18.0
38 marshmallow==2.18.0
39 pyramid==2.0.2
39 pyramid==2.0.2
@@ -46,7 +46,7 b' channelstream==0.7.1'
46 venusian==3.0.0
46 venusian==3.0.0
47 webob==1.8.7
47 webob==1.8.7
48 zope.deprecation==5.0.0
48 zope.deprecation==5.0.0
49 zope.interface==6.4.post2
49 zope.interface==7.0.3
50 pyramid-jinja2==2.10
50 pyramid-jinja2==2.10
51 jinja2==3.1.2
51 jinja2==3.1.2
52 markupsafe==2.1.2
52 markupsafe==2.1.2
@@ -61,7 +61,7 b' channelstream==0.7.1'
61 venusian==3.0.0
61 venusian==3.0.0
62 webob==1.8.7
62 webob==1.8.7
63 zope.deprecation==5.0.0
63 zope.deprecation==5.0.0
64 zope.interface==6.4.post2
64 zope.interface==7.0.3
65 zope.deprecation==5.0.0
65 zope.deprecation==5.0.0
66 python-dateutil==2.8.2
66 python-dateutil==2.8.2
67 six==1.16.0
67 six==1.16.0
@@ -87,13 +87,13 b' dogpile.cache==1.3.3'
87 pbr==5.11.1
87 pbr==5.11.1
88 formencode==2.1.0
88 formencode==2.1.0
89 six==1.16.0
89 six==1.16.0
90 fsspec==2024.6.0
90 fsspec==2024.9.0
91 gunicorn==23.0.0
91 gunicorn==23.0.0
92 packaging==24.1
92 packaging==24.1
93 gevent==24.2.1
93 gevent==24.2.1
94 greenlet==3.0.3
94 greenlet==3.0.3
95 zope.event==5.0.0
95 zope.event==5.0.0
96 zope.interface==6.4.post2
96 zope.interface==7.0.3
97 ipython==8.26.0
97 ipython==8.26.0
98 decorator==5.1.1
98 decorator==5.1.1
99 jedi==0.19.1
99 jedi==0.19.1
@@ -167,7 +167,7 b' nbconvert==7.7.3'
167 tinycss2==1.2.1
167 tinycss2==1.2.1
168 webencodings==0.5.1
168 webencodings==0.5.1
169 traitlets==5.14.3
169 traitlets==5.14.3
170 orjson==3.10.6
170 orjson==3.10.7
171 paste==3.10.1
171 paste==3.10.1
172 premailer==3.10.0
172 premailer==3.10.0
173 cachetools==5.3.3
173 cachetools==5.3.3
@@ -201,13 +201,13 b' pyramid-mailer==0.15.1'
201 venusian==3.0.0
201 venusian==3.0.0
202 webob==1.8.7
202 webob==1.8.7
203 zope.deprecation==5.0.0
203 zope.deprecation==5.0.0
204 zope.interface==6.4.post2
204 zope.interface==7.0.3
205 repoze.sendmail==4.4.1
205 repoze.sendmail==4.4.1
206 transaction==3.1.0
206 transaction==5.0.0
207 zope.interface==6.4.post2
207 zope.interface==7.0.3
208 zope.interface==6.4.post2
208 zope.interface==7.0.3
209 transaction==3.1.0
209 transaction==5.0.0
210 zope.interface==6.4.post2
210 zope.interface==7.0.3
211 pyramid-mako==1.1.0
211 pyramid-mako==1.1.0
212 mako==1.2.4
212 mako==1.2.4
213 markupsafe==2.1.2
213 markupsafe==2.1.2
@@ -221,7 +221,7 b' pyramid-mako==1.1.0'
221 venusian==3.0.0
221 venusian==3.0.0
222 webob==1.8.7
222 webob==1.8.7
223 zope.deprecation==5.0.0
223 zope.deprecation==5.0.0
224 zope.interface==6.4.post2
224 zope.interface==7.0.3
225 python-ldap==3.4.3
225 python-ldap==3.4.3
226 pyasn1==0.4.8
226 pyasn1==0.4.8
227 pyasn1-modules==0.2.8
227 pyasn1-modules==0.2.8
@@ -236,13 +236,13 b' python3-saml==1.16.0'
236 xmlsec==1.3.14
236 xmlsec==1.3.14
237 lxml==5.3.0
237 lxml==5.3.0
238 pyyaml==6.0.1
238 pyyaml==6.0.1
239 redis==5.0.4
239 redis==5.1.0
240 async-timeout==4.0.3
240 async-timeout==4.0.3
241 regex==2022.10.31
241 regex==2022.10.31
242 routes==2.5.1
242 routes==2.5.1
243 repoze.lru==0.7
243 repoze.lru==0.7
244 six==1.16.0
244 six==1.16.0
245 s3fs==2024.6.0
245 s3fs==2024.9.0
246 aiobotocore==2.13.0
246 aiobotocore==2.13.0
247 aiohttp==3.9.5
247 aiohttp==3.9.5
248 aiosignal==1.3.1
248 aiosignal==1.3.1
@@ -269,7 +269,7 b' s3fs==2024.6.0'
269 yarl==1.9.4
269 yarl==1.9.4
270 idna==3.4
270 idna==3.4
271 multidict==6.0.5
271 multidict==6.0.5
272 fsspec==2024.6.0
272 fsspec==2024.9.0
273 simplejson==3.19.2
273 simplejson==3.19.2
274 sshpubkeys==3.3.1
274 sshpubkeys==3.3.1
275 cryptography==40.0.2
275 cryptography==40.0.2
@@ -67,7 +67,7 b' def admin_routes(config):'
67
67
68 config.add_route(
68 config.add_route(
69 name='admin_security_modify_allowed_vcs_client_versions',
69 name='admin_security_modify_allowed_vcs_client_versions',
70 pattern='/security/modify/allowed_vcs_client_versions')
70 pattern=ADMIN_PREFIX + '/security/modify/allowed_vcs_client_versions')
71 config.add_view(
71 config.add_view(
72 AdminSecurityView,
72 AdminSecurityView,
73 attr='vcs_whitelisted_client_versions_edit',
73 attr='vcs_whitelisted_client_versions_edit',
@@ -17,13 +17,8 b''
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18
18
19 import logging
19 import logging
20 import formencode
21
20
22 from rhodecode import BACKENDS
23 from rhodecode.apps._base import BaseAppView
21 from rhodecode.apps._base import BaseAppView
24 from rhodecode.model.meta import Session
25 from rhodecode.model.settings import SettingsModel
26 from rhodecode.model.forms import WhitelistedVcsClientsForm
27 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
22 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
28
23
29 log = logging.getLogger(__name__)
24 log = logging.getLogger(__name__)
@@ -42,31 +37,10 b' class AdminSecurityView(BaseAppView):'
42 c.active = 'security'
37 c.active = 'security'
43 return self._get_template_context(c)
38 return self._get_template_context(c)
44
39
40
45 @LoginRequired()
41 @LoginRequired()
46 @HasPermissionAllDecorator('hg.admin')
42 @HasPermissionAllDecorator('hg.admin')
47 def vcs_whitelisted_client_versions_edit(self):
43 def admin_security_modify_allowed_vcs_client_versions(self):
48 _ = self.request.translate
49 c = self.load_default_context()
44 c = self.load_default_context()
50 render_ctx = {}
45 c.active = 'security'
51 settings = SettingsModel()
46 return self._get_template_context(c)
52 form = WhitelistedVcsClientsForm(_, )()
53 if self.request.method == 'POST':
54 try:
55 result = form.to_python(self.request.POST)
56 for k, v in result.items():
57 if v:
58 setting = settings.create_or_update_setting(name=f'{k}_allowed_clients', val=v)
59 Session().add(setting)
60 Session().commit()
61
62 except formencode.Invalid as errors:
63 render_ctx.update({
64 'errors': errors.error_dict
65 })
66 for key in BACKENDS.keys():
67 verbose_name = f"initial_{key}"
68 if existing := settings.get_setting_by_name(name=f'{key}_allowed_clients'):
69 render_ctx[verbose_name] = existing.app_settings_value
70 else:
71 render_ctx[verbose_name] = '*'
72 return self._get_template_context(c, **render_ctx)
@@ -82,7 +82,7 b' class AdminSettingsView(BaseAppView):'
82 if k == '/':
82 if k == '/':
83 k = 'root_path'
83 k = 'root_path'
84
84
85 if k in ['push_ssl', 'publish', 'enabled']:
85 if k in ['publish', 'enabled']:
86 v = str2bool(v)
86 v = str2bool(v)
87
87
88 if k.find('.') != -1:
88 if k.find('.') != -1:
@@ -164,7 +164,6 b' class AdminSettingsView(BaseAppView):'
164 return Response(html)
164 return Response(html)
165
165
166 try:
166 try:
167 model.update_global_ssl_setting(form_result['web_push_ssl'])
168 model.update_global_hook_settings(form_result)
167 model.update_global_hook_settings(form_result)
169
168
170 model.create_or_update_global_svn_settings(form_result)
169 model.create_or_update_global_svn_settings(form_result)
@@ -52,7 +52,8 b' def sanitize_settings_and_apply_defaults'
52 default=False,
52 default=False,
53 parser='bool')
53 parser='bool')
54
54
55 logging_conf = jn(os.path.dirname(global_config.get('__file__')), 'logging.ini')
55 ini_loc = os.path.dirname(global_config.get('__file__'))
56 logging_conf = jn(ini_loc, 'logging.ini')
56 settings_maker.enable_logging(logging_conf, level='INFO' if debug_enabled else 'DEBUG')
57 settings_maker.enable_logging(logging_conf, level='INFO' if debug_enabled else 'DEBUG')
57
58
58 # Default includes, possible to change as a user
59 # Default includes, possible to change as a user
@@ -95,6 +96,11 b' def sanitize_settings_and_apply_defaults'
95 settings_maker.make_setting('gzip_responses', False, parser='bool')
96 settings_maker.make_setting('gzip_responses', False, parser='bool')
96 settings_maker.make_setting('startup.import_repos', 'false', parser='bool')
97 settings_maker.make_setting('startup.import_repos', 'false', parser='bool')
97
98
99 # License settings.
100 settings_maker.make_setting('license.hide_license_info', False, parser='bool')
101 settings_maker.make_setting('license.import_path', jn(ini_loc, 'rhodecode_enterprise.license'))
102 settings_maker.make_setting('license.import_path_mode', 'if-missing')
103
98 # statsd
104 # statsd
99 settings_maker.make_setting('statsd.enabled', False, parser='bool')
105 settings_maker.make_setting('statsd.enabled', False, parser='bool')
100 settings_maker.make_setting('statsd.statsd_host', 'statsd-exporter', parser='string')
106 settings_maker.make_setting('statsd.statsd_host', 'statsd-exporter', parser='string')
@@ -50,7 +50,7 b' from rhodecode.lib.utils2 import Attribu'
50 from rhodecode.lib.exc_tracking import store_exception, format_exc
50 from rhodecode.lib.exc_tracking import store_exception, format_exc
51 from rhodecode.subscribers import (
51 from rhodecode.subscribers import (
52 scan_repositories_if_enabled, write_js_routes_if_enabled,
52 scan_repositories_if_enabled, write_js_routes_if_enabled,
53 write_metadata_if_needed, write_usage_data)
53 write_metadata_if_needed, write_usage_data, import_license_if_present)
54 from rhodecode.lib.statsd_client import StatsdClient
54 from rhodecode.lib.statsd_client import StatsdClient
55
55
56 log = logging.getLogger(__name__)
56 log = logging.getLogger(__name__)
@@ -400,7 +400,8 b' def includeme(config, auth_resources=Non'
400 pyramid.events.ApplicationCreated)
400 pyramid.events.ApplicationCreated)
401 config.add_subscriber(write_js_routes_if_enabled,
401 config.add_subscriber(write_js_routes_if_enabled,
402 pyramid.events.ApplicationCreated)
402 pyramid.events.ApplicationCreated)
403
403 config.add_subscriber(import_license_if_present,
404 pyramid.events.ApplicationCreated)
404
405
405 # Set the default renderer for HTML templates to mako.
406 # Set the default renderer for HTML templates to mako.
406 config.add_mako_renderer('.html')
407 config.add_mako_renderer('.html')
@@ -570,7 +570,6 b' class DbManage(object):'
570 self.create_ui_settings(path)
570 self.create_ui_settings(path)
571
571
572 ui_config = [
572 ui_config = [
573 ('web', 'push_ssl', 'False'),
574 ('web', 'allow_archive', 'gz zip bz2'),
573 ('web', 'allow_archive', 'gz zip bz2'),
575 ('web', 'allow_push', '*'),
574 ('web', 'allow_push', '*'),
576 ('web', 'baseurl', '/'),
575 ('web', 'baseurl', '/'),
@@ -339,21 +339,6 b' class SimpleVCS(object):'
339 log.exception('Failed to read http scheme')
339 log.exception('Failed to read http scheme')
340 return 'http'
340 return 'http'
341
341
342 def _check_ssl(self, environ, start_response):
343 """
344 Checks the SSL check flag and returns False if SSL is not present
345 and required True otherwise
346 """
347 org_proto = environ['wsgi._org_proto']
348 # check if we have SSL required ! if not it's a bad request !
349 require_ssl = str2bool(self.repo_vcs_config.get('web', 'push_ssl'))
350 if require_ssl and org_proto == 'http':
351 log.debug(
352 'Bad request: detected protocol is `%s` and '
353 'SSL/HTTPS is required.', org_proto)
354 return False
355 return True
356
357 def _get_default_cache_ttl(self):
342 def _get_default_cache_ttl(self):
358 # take AUTH_CACHE_TTL from the `rhodecode` auth plugin
343 # take AUTH_CACHE_TTL from the `rhodecode` auth plugin
359 plugin = loadplugin('egg:rhodecode-enterprise-ce#rhodecode')
344 plugin = loadplugin('egg:rhodecode-enterprise-ce#rhodecode')
@@ -373,12 +358,6 b' class SimpleVCS(object):'
373 meta.Session.remove()
358 meta.Session.remove()
374
359
375 def _handle_request(self, environ, start_response):
360 def _handle_request(self, environ, start_response):
376 if not self._check_ssl(environ, start_response):
377 reason = ('SSL required, while RhodeCode was unable '
378 'to detect this as SSL request')
379 log.debug('User not allowed to proceed, %s', reason)
380 return HTTPNotAcceptable(reason)(environ, start_response)
381
382 if not self.url_repo_name:
361 if not self.url_repo_name:
383 log.warning('Repository name is empty: %s', self.url_repo_name)
362 log.warning('Repository name is empty: %s', self.url_repo_name)
384 # failed to get repo name, we fail now
363 # failed to get repo name, we fail now
@@ -159,11 +159,18 b' def detect_vcs_request(environ, backends'
159 # favicon often requested by browsers
159 # favicon often requested by browsers
160 'favicon.ico',
160 'favicon.ico',
161
161
162 # static files no detection
163 '_static++',
164
165 # debug-toolbar
166 '_debug_toolbar++',
167
162 # e.g /_file_store/download
168 # e.g /_file_store/download
163 '_file_store++',
169 '_file_store++',
164
170
165 # login
171 # login
166 "_admin/login",
172 f"{ADMIN_PREFIX}/login",
173 f"{ADMIN_PREFIX}/logout",
167
174
168 # 2fa
175 # 2fa
169 f"{ADMIN_PREFIX}/check_2fa",
176 f"{ADMIN_PREFIX}/check_2fa",
@@ -178,12 +185,6 b' def detect_vcs_request(environ, backends'
178 # _admin/my_account is safe too
185 # _admin/my_account is safe too
179 f'{ADMIN_PREFIX}/my_account++',
186 f'{ADMIN_PREFIX}/my_account++',
180
187
181 # static files no detection
182 '_static++',
183
184 # debug-toolbar
185 '_debug_toolbar++',
186
187 # skip ops ping, status
188 # skip ops ping, status
188 f'{ADMIN_PREFIX}/ops/ping',
189 f'{ADMIN_PREFIX}/ops/ping',
189 f'{ADMIN_PREFIX}/ops/status',
190 f'{ADMIN_PREFIX}/ops/status',
@@ -193,11 +194,14 b' def detect_vcs_request(environ, backends'
193
194
194 '++/repo_creating_check'
195 '++/repo_creating_check'
195 ]
196 ]
197
196 path_info = get_path_info(environ)
198 path_info = get_path_info(environ)
197 path_url = path_info.lstrip('/')
199 path_url = path_info.lstrip('/')
198 req_method = environ.get('REQUEST_METHOD')
200 req_method = environ.get('REQUEST_METHOD')
199
201
200 for item in white_list:
202 for item in white_list:
203 item = item.lstrip('/')
204
201 if item.endswith('++') and path_url.startswith(item[:-2]):
205 if item.endswith('++') and path_url.startswith(item[:-2]):
202 log.debug('path `%s` in whitelist (match:%s), skipping...', path_url, item)
206 log.debug('path `%s` in whitelist (match:%s), skipping...', path_url, item)
203 return handler
207 return handler
@@ -108,11 +108,10 b' def command(ini_path, force_yes, user, e'
108 dbmanage.create_permissions()
108 dbmanage.create_permissions()
109 dbmanage.populate_default_permissions()
109 dbmanage.populate_default_permissions()
110 if apply_license_key:
110 if apply_license_key:
111 try:
111 from rhodecode.model.license import apply_license_from_file
112 from rc_license.models import apply_trial_license_if_missing
112 license_file_path = config.get('license.import_path')
113 apply_trial_license_if_missing(force=True)
113 if license_file_path:
114 except ImportError:
114 apply_license_from_file(license_file_path, force=True)
115 pass
116
115
117 Session().commit()
116 Session().commit()
118
117
@@ -391,8 +391,7 b' def prepare_config_data(clear_session=Tr'
391 safe_str(setting.section), safe_str(setting.key),
391 safe_str(setting.section), safe_str(setting.key),
392 safe_str(setting.value)))
392 safe_str(setting.value)))
393 if setting.key == 'push_ssl':
393 if setting.key == 'push_ssl':
394 # force set push_ssl requirement to False, rhodecode
394 # force set push_ssl requirement to False this is deprecated, and we must force it to False
395 # handles that
396 config.append((
395 config.append((
397 safe_str(setting.section), safe_str(setting.key), False))
396 safe_str(setting.section), safe_str(setting.key), False))
398 config_getter = ConfigGet()
397 config_getter = ConfigGet()
@@ -468,7 +468,6 b' def ApplicationUiSettingsForm(localizer)'
468 _ = localizer
468 _ = localizer
469
469
470 class _ApplicationUiSettingsForm(_BaseVcsSettingsForm):
470 class _ApplicationUiSettingsForm(_BaseVcsSettingsForm):
471 web_push_ssl = v.StringBoolean(if_missing=False)
472 extensions_hggit = v.StringBoolean(if_missing=False)
471 extensions_hggit = v.StringBoolean(if_missing=False)
473 new_svn_branch = v.ValidSvnPattern(localizer, section='vcs_svn_branch')
472 new_svn_branch = v.ValidSvnPattern(localizer, section='vcs_svn_branch')
474 new_svn_tag = v.ValidSvnPattern(localizer, section='vcs_svn_tag')
473 new_svn_tag = v.ValidSvnPattern(localizer, section='vcs_svn_tag')
@@ -499,7 +499,6 b' class VcsSettingsModel(object):'
499
499
500 SVN_BRANCH_SECTION = 'vcs_svn_branch'
500 SVN_BRANCH_SECTION = 'vcs_svn_branch'
501 SVN_TAG_SECTION = 'vcs_svn_tag'
501 SVN_TAG_SECTION = 'vcs_svn_tag'
502 SSL_SETTING = ('web', 'push_ssl')
503 PATH_SETTING = ('paths', '/')
502 PATH_SETTING = ('paths', '/')
504
503
505 def __init__(self, sa=None, repo=None):
504 def __init__(self, sa=None, repo=None):
@@ -704,10 +703,6 b' class VcsSettingsModel(object):'
704 # branch/tags patterns
703 # branch/tags patterns
705 self._create_svn_settings(self.global_settings, data)
704 self._create_svn_settings(self.global_settings, data)
706
705
707 def update_global_ssl_setting(self, value):
708 self._create_or_update_ui(
709 self.global_settings, *self.SSL_SETTING, value=value)
710
711 @assert_repo_settings
706 @assert_repo_settings
712 def delete_repo_svn_pattern(self, id_):
707 def delete_repo_svn_pattern(self, id_):
713 ui = self.repo_settings.UiDbModel.get(id_)
708 ui = self.repo_settings.UiDbModel.get(id_)
@@ -205,7 +205,7 b' def write_usage_data(event):'
205 return
205 return
206
206
207 def get_update_age(dest_file):
207 def get_update_age(dest_file):
208 now = datetime.datetime.utcnow()
208 now = datetime.datetime.now(datetime.UTC)
209
209
210 with open(dest_file, 'rb') as f:
210 with open(dest_file, 'rb') as f:
211 data = ext_json.json.loads(f.read())
211 data = ext_json.json.loads(f.read())
@@ -216,10 +216,9 b' def write_usage_data(event):'
216
216
217 return 0
217 return 0
218
218
219 utc_date = datetime.datetime.utcnow()
219 utc_date = datetime.datetime.now(datetime.UTC)
220 hour_quarter = int(math.ceil((utc_date.hour + utc_date.minute/60.0) / 6.))
220 hour_quarter = int(math.ceil((utc_date.hour + utc_date.minute/60.0) / 6.))
221 fname = '.rc_usage_{date.year}{date.month:02d}{date.day:02d}_{hour}.json'.format(
221 fname = f'.rc_usage_{utc_date.year}{utc_date.month:02d}{utc_date.day:02d}_{hour_quarter}.json'
222 date=utc_date, hour=hour_quarter)
223 ini_loc = os.path.dirname(rhodecode.CONFIG.get('__file__'))
222 ini_loc = os.path.dirname(rhodecode.CONFIG.get('__file__'))
224
223
225 usage_dir = os.path.join(ini_loc, '.rcusage')
224 usage_dir = os.path.join(ini_loc, '.rcusage')
@@ -314,6 +313,22 b' def write_js_routes_if_enabled(event):'
314 log.exception('Failed to write routes.js into %s', jsroutes_file_path)
313 log.exception('Failed to write routes.js into %s', jsroutes_file_path)
315
314
316
315
316 def import_license_if_present(event):
317 """
318 This is subscribed to the `pyramid.events.ApplicationCreated` event. It
319 does a import license key based on a presence of the file.
320 """
321 settings = event.app.registry.settings
322
323 license_file_path = settings.get('license.import_path')
324 force = settings.get('license.import_path_mode') == 'force'
325 if license_file_path:
326 from rhodecode.model.meta import Session
327 from rhodecode.model.license import apply_license_from_file
328 apply_license_from_file(license_file_path, force=force)
329 Session().commit()
330
331
317 class Subscriber(object):
332 class Subscriber(object):
318 """
333 """
319 Base class for subscribers to the pyramid event system.
334 Base class for subscribers to the pyramid event system.
@@ -38,42 +38,13 b''
38 <h3 class="panel-title">${_('Allowed client versions')}</h3>
38 <h3 class="panel-title">${_('Allowed client versions')}</h3>
39 </div>
39 </div>
40 <div class="panel-body">
40 <div class="panel-body">
41 %if c.rhodecode_edition_id != 'EE':
42 <h4>${_('This feature is available in RhodeCode EE edition only. Contact {sales_email} to obtain a trial license.').format(sales_email='<a href="mailto:sales@rhodecode.com">sales@rhodecode.com</a>')|n}</h4>
41 <h4>${_('This feature is available in RhodeCode EE edition only. Contact {sales_email} to obtain a trial license.').format(sales_email='<a href="mailto:sales@rhodecode.com">sales@rhodecode.com</a>')|n}</h4>
43 <p>
42 <p>
44 ${_('Some outdated client versions may have security vulnerabilities. This section have rules for whitelisting versions of clients for Git, Mercurial and SVN.')}
43 ${_('Some outdated client versions may have security vulnerabilities. This section have rules for whitelisting versions of clients for Git, Mercurial and SVN.')}
45 </p>
44 </p>
46 %else:
47 <div class="inner form" id="container">
48 </div>
45 </div>
49 %endif
46
50 </div>
51
47
52 </div>
48 </div>
53
49
54 <script>
55 $(document).ready(function() {
56 $.ajax({
57 url: pyroutes.url('admin_security_modify_allowed_vcs_client_versions'),
58 type: 'GET',
59 success: function(response) {
60 $('#container').html(response);
61 },
62 });
63 $(document).on('submit', '#allowed_clients_form', function(event) {
64 event.preventDefault();
65 var formData = $(this).serialize();
66
67 $.ajax({
68 url: pyroutes.url('admin_security_modify_allowed_vcs_client_versions'),
69 type: 'POST',
70 data: formData,
71 success: function(response) {
72 $('#container').html(response);
73 },
74 });
75 });
76 });
77 </script>
78
79 </%def>
50 </%def>
@@ -5,22 +5,7 b''
5
5
6 <%def name="vcs_settings_fields(suffix='', svn_branch_patterns=None, svn_tag_patterns=None, repo_type=None, display_globals=False, **kwargs)">
6 <%def name="vcs_settings_fields(suffix='', svn_branch_patterns=None, svn_tag_patterns=None, repo_type=None, display_globals=False, **kwargs)">
7 % if display_globals:
7 % if display_globals:
8 <div class="panel panel-default">
8
9 <div class="panel-heading" id="general">
10 <h3 class="panel-title">${_('General')}<a class="permalink" href="#general"></a></h3>
11 </div>
12 <div class="panel-body">
13 <div class="field">
14 <div class="checkbox">
15 ${h.checkbox('web_push_ssl' + suffix, 'True')}
16 <label for="web_push_ssl${suffix}">${_('Require SSL for vcs operations')}</label>
17 </div>
18 <div class="label">
19 <span class="help-block">${_('Activate to set RhodeCode to require SSL for pushing or pulling. If SSL certificate is missing it will return a HTTP Error 406: Not Acceptable.')}</span>
20 </div>
21 </div>
22 </div>
23 </div>
24 % endif
9 % endif
25
10
26 % if display_globals or repo_type in ['git', 'hg']:
11 % if display_globals or repo_type in ['git', 'hg']:
@@ -120,7 +120,6 b' def test_get_config(user_util, baseapp, '
120
120
121 expected_config = [
121 expected_config = [
122 ('vcs_svn_tag', 'ff89f8c714d135d865f44b90e5413b88de19a55f', '/tags/*'),
122 ('vcs_svn_tag', 'ff89f8c714d135d865f44b90e5413b88de19a55f', '/tags/*'),
123 ('web', 'push_ssl', 'False'),
124 ('web', 'allow_push', '*'),
123 ('web', 'allow_push', '*'),
125 ('web', 'allow_archive', 'gz zip bz2'),
124 ('web', 'allow_archive', 'gz zip bz2'),
126 ('web', 'baseurl', '/'),
125 ('web', 'baseurl', '/'),
@@ -239,7 +239,6 b' class TestShadowRepoExposure(object):'
239 """
239 """
240 controller = StubVCSController(
240 controller = StubVCSController(
241 baseapp.config.get_settings(), request_stub.registry)
241 baseapp.config.get_settings(), request_stub.registry)
242 controller._check_ssl = mock.Mock()
243 controller.is_shadow_repo = True
242 controller.is_shadow_repo = True
244 controller._action = 'pull'
243 controller._action = 'pull'
245 controller._is_shadow_repo_dir = True
244 controller._is_shadow_repo_dir = True
@@ -267,7 +266,6 b' class TestShadowRepoExposure(object):'
267 """
266 """
268 controller = StubVCSController(
267 controller = StubVCSController(
269 baseapp.config.get_settings(), request_stub.registry)
268 baseapp.config.get_settings(), request_stub.registry)
270 controller._check_ssl = mock.Mock()
271 controller.is_shadow_repo = True
269 controller.is_shadow_repo = True
272 controller._action = 'pull'
270 controller._action = 'pull'
273 controller._is_shadow_repo_dir = False
271 controller._is_shadow_repo_dir = False
@@ -291,7 +289,6 b' class TestShadowRepoExposure(object):'
291 """
289 """
292 controller = StubVCSController(
290 controller = StubVCSController(
293 baseapp.config.get_settings(), request_stub.registry)
291 baseapp.config.get_settings(), request_stub.registry)
294 controller._check_ssl = mock.Mock()
295 controller.is_shadow_repo = True
292 controller.is_shadow_repo = True
296 controller._action = 'push'
293 controller._action = 'push'
297 controller.stub_response_body = (b'dummy body value',)
294 controller.stub_response_body = (b'dummy body value',)
@@ -578,17 +578,6 b' class TestCreateOrUpdateRepoHgSettings(o'
578 assert str(exc_info.value) == 'Repository is not specified'
578 assert str(exc_info.value) == 'Repository is not specified'
579
579
580
580
581 class TestUpdateGlobalSslSetting(object):
582 def test_updates_global_hg_settings(self):
583 model = VcsSettingsModel()
584 with mock.patch.object(model, '_create_or_update_ui') as create_mock:
585 model.update_global_ssl_setting('False')
586 Session().commit()
587
588 create_mock.assert_called_once_with(
589 model.global_settings, 'web', 'push_ssl', value='False')
590
591
592 class TestCreateOrUpdateGlobalHgSettings(object):
581 class TestCreateOrUpdateGlobalHgSettings(object):
593 FORM_DATA = {
582 FORM_DATA = {
594 'extensions_largefiles': False,
583 'extensions_largefiles': False,
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now