##// END OF EJS Templates
auth, performance: use cache_ttl for anonymous access taken from the rhodecode plugin....
marcink -
r2425:46757b44 default
parent child Browse files
Show More
@@ -38,7 +38,7 b' from zope.cachedescriptors.property impo'
38 38
39 39 import rhodecode
40 40 from rhodecode.authentication.base import (
41 authenticate, get_perms_cache_manager, VCS_TYPE)
41 authenticate, get_perms_cache_manager, VCS_TYPE, loadplugin)
42 42 from rhodecode.lib import caches
43 43 from rhodecode.lib.auth import AuthUser, HasPermissionAnyMiddleware
44 44 from rhodecode.lib.base import (
@@ -360,6 +360,14 b' class SimpleVCS(object):'
360 360 return False
361 361 return True
362 362
363 def _get_default_cache_ttl(self):
364 # take AUTH_CACHE_TTL from the `rhodecode` auth plugin
365 plugin = loadplugin('egg:rhodecode-enterprise-ce#rhodecode')
366 plugin_settings = plugin.get_settings()
367 plugin_cache_active, cache_ttl = plugin.get_ttl_cache(
368 plugin_settings) or (False, 0)
369 return plugin_cache_active, cache_ttl
370
363 371 def __call__(self, environ, start_response):
364 372 try:
365 373 return self._handle_request(environ, start_response)
@@ -419,9 +427,13 b' class SimpleVCS(object):'
419 427 anonymous_user = User.get_default_user()
420 428 username = anonymous_user.username
421 429 if anonymous_user.active:
430 plugin_cache_active, cache_ttl = self._get_default_cache_ttl()
422 431 # ONLY check permissions if the user is activated
423 432 anonymous_perm = self._check_permission(
424 action, anonymous_user, self.acl_repo_name, ip_addr)
433 action, anonymous_user, self.acl_repo_name, ip_addr,
434 plugin_id='anonymous_access',
435 plugin_cache_active=plugin_cache_active, cache_ttl=cache_ttl,
436 )
425 437 else:
426 438 anonymous_perm = False
427 439
@@ -229,6 +229,9 b' class TestShadowRepoExposure(object):'
229 229 controller._action = 'pull'
230 230 controller._is_shadow_repo_dir = True
231 231 controller.stub_response_body = 'dummy body value'
232 controller._get_default_cache_ttl = mock.Mock(
233 return_value=(False, 0))
234
232 235 environ_stub = {
233 236 'HTTP_HOST': 'test.example.com',
234 237 'HTTP_ACCEPT': 'application/mercurial',
General Comments 0
You need to be logged in to leave comments. Login now