##// END OF EJS Templates
ssh: introduce ini setting 'ssh_enabled', disabled by default...
Thomas De Schampheleire -
r7677:6da70f45 default
parent child Browse files
Show More
@@ -226,6 +226,13 b' allow_custom_hooks_settings = True'
226 226 # CHANGELOG
227 227
228 228 ####################################
229 ### SSH CONFIG ####
230 ####################################
231
232 ## SSH is disabled by default, until an Administrator decides to enable it.
233 ssh_enabled = false
234
235 ####################################
229 236 ### CELERY CONFIG ####
230 237 ####################################
231 238
@@ -408,6 +408,7 b' class BaseController(TGController):'
408 408 ## INI stored
409 409 c.visual.allow_repo_location_change = str2bool(config.get('allow_repo_location_change', True))
410 410 c.visual.allow_custom_hooks_settings = str2bool(config.get('allow_custom_hooks_settings', True))
411 c.ssh_enabled = str2bool(config.get('ssh_enabled', False))
411 412
412 413 c.instance_id = config.get('instance_id')
413 414 c.issues_url = config.get('bugtracker', url('issues_url'))
@@ -636,3 +637,15 b' def jsonify(func, *args, **kwargs):'
636 637 log.warning(msg)
637 638 log.debug("Returning JSON wrapped action output")
638 639 return json.dumps(data, encoding='utf-8')
640
641 @decorator.decorator
642 def IfSshEnabled(func, *args, **kwargs):
643 """Decorator for functions that can only be called if SSH access is enabled.
644
645 If SSH access is disabled in the configuration file, HTTPNotFound is raised.
646 """
647 if not c.ssh_enabled:
648 from kallithea.lib import helpers as h
649 h.flash(_("SSH access is disabled."), category='warning')
650 raise webob.exc.HTTPNotFound()
651 return func(*args, **kwargs)
@@ -323,6 +323,13 b' allow_custom_hooks_settings = True'
323 323 # CHANGELOG
324 324
325 325 <%text>####################################</%text>
326 <%text>### SSH CONFIG ####</%text>
327 <%text>####################################</%text>
328
329 <%text>## SSH is disabled by default, until an Administrator decides to enable it.</%text>
330 ssh_enabled = false
331
332 <%text>####################################</%text>
326 333 <%text>### CELERY CONFIG ####</%text>
327 334 <%text>####################################</%text>
328 335
@@ -42,6 +42,7 b' def pytest_configure():'
42 42 'port': '4999',
43 43 },
44 44 '[app:main]': {
45 'ssh_enabled': 'true',
45 46 'app_instance_uuid': 'test',
46 47 'show_revision_number': 'true',
47 48 'beaker.cache.sql_cache_short.expire': '1',
General Comments 0
You need to be logged in to leave comments. Login now