##// END OF EJS Templates
caches: enable cache TTL=30s for auth-plugins....
marcink -
r2954:5ef9c564 default
parent child Browse files
Show More
@@ -37,6 +37,7 b' log = logging.getLogger(__name__)'
37 # Plugin ID prefixes to distinct between normal and legacy plugins.
37 # Plugin ID prefixes to distinct between normal and legacy plugins.
38 plugin_prefix = 'egg:'
38 plugin_prefix = 'egg:'
39 legacy_plugin_prefix = 'py:'
39 legacy_plugin_prefix = 'py:'
40 plugin_default_auth_ttl = 30
40
41
41
42
42 # TODO: Currently this is only used to discover the authentication plugins.
43 # TODO: Currently this is only used to discover the authentication plugins.
@@ -439,7 +439,11 b' class RhodeCodeAuthPluginBase(object):'
439
439
440 def get_ttl_cache(self, settings=None):
440 def get_ttl_cache(self, settings=None):
441 plugin_settings = settings or self.get_settings()
441 plugin_settings = settings or self.get_settings()
442 cache_ttl = 0
442 # we set default to 30, we make a compromise here,
443 # performance > security, mostly due to LDAP/SVN, majority
444 # of users pick cache_ttl to be enabled
445 from rhodecode.authentication import plugin_default_auth_ttl
446 cache_ttl = plugin_default_auth_ttl
443
447
444 if isinstance(self.AUTH_CACHE_TTL, (int, long)):
448 if isinstance(self.AUTH_CACHE_TTL, (int, long)):
445 # plugin cache set inside is more important than the settings value
449 # plugin cache set inside is more important than the settings value
@@ -20,6 +20,7 b''
20
20
21 import colander
21 import colander
22
22
23 from rhodecode.authentication import plugin_default_auth_ttl
23 from rhodecode.translation import _
24 from rhodecode.translation import _
24
25
25
26
@@ -39,7 +40,7 b' class AuthnPluginSettingsSchemaBase(cola'
39 )
40 )
40 cache_ttl = colander.SchemaNode(
41 cache_ttl = colander.SchemaNode(
41 colander.Int(),
42 colander.Int(),
42 default=0,
43 default=plugin_default_auth_ttl,
43 description=_('Amount of seconds to cache the authentication and '
44 description=_('Amount of seconds to cache the authentication and '
44 'permissions check response call for this plugin. \n'
45 'permissions check response call for this plugin. \n'
45 'Useful for expensive calls like LDAP to improve the '
46 'Useful for expensive calls like LDAP to improve the '
@@ -30,10 +30,7 b' class EnabledAuthPlugin(object):'
30 """
30 """
31
31
32 def __init__(self, plugin):
32 def __init__(self, plugin):
33 self.new_value = set([
33 self.new_value = {'egg:rhodecode-enterprise-ce#rhodecode', plugin.get_id()}
34 'egg:rhodecode-enterprise-ce#rhodecode',
35 plugin.get_id()
36 ])
37
34
38 def __enter__(self):
35 def __enter__(self):
39 from rhodecode.model.settings import SettingsModel
36 from rhodecode.model.settings import SettingsModel
@@ -47,7 +44,7 b' class EnabledAuthPlugin(object):'
47 'auth_plugins', ','.join(self._old_value))
44 'auth_plugins', ','.join(self._old_value))
48
45
49
46
50 class DisabledAuthPlugin():
47 class DisabledAuthPlugin(object):
51 """
48 """
52 Context manager that updates the 'auth_plugins' setting in DB to disable
49 Context manager that updates the 'auth_plugins' setting in DB to disable
53 a plugin. Previous setting is restored on exit.
50 a plugin. Previous setting is restored on exit.
@@ -18,12 +18,10 b''
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
22 import os
21 import os
23 import logging
22 import logging
24 import rhodecode
23 import rhodecode
25
24
26
27 from rhodecode.config import utils
25 from rhodecode.config import utils
28
26
29 from rhodecode.lib.utils import load_rcextensions
27 from rhodecode.lib.utils import load_rcextensions
@@ -52,6 +50,8 b' def load_pyramid_environment(global_conf'
52 if settings['is_test']:
50 if settings['is_test']:
53 rhodecode.is_test = True
51 rhodecode.is_test = True
54 rhodecode.disable_error_handler = True
52 rhodecode.disable_error_handler = True
53 from rhodecode import authentication
54 authentication.plugin_default_auth_ttl = 0
55
55
56 utils.initialize_test_environment(settings_merged)
56 utils.initialize_test_environment(settings_merged)
57
57
General Comments 0
You need to be logged in to leave comments. Login now