Show More
@@ -38,7 +38,7 b' from zope.cachedescriptors.property impo' | |||||
38 |
|
38 | |||
39 | import rhodecode |
|
39 | import rhodecode | |
40 | from rhodecode.authentication.base import ( |
|
40 | from rhodecode.authentication.base import ( | |
41 | authenticate, get_perms_cache_manager, VCS_TYPE) |
|
41 | authenticate, get_perms_cache_manager, VCS_TYPE, loadplugin) | |
42 | from rhodecode.lib import caches |
|
42 | from rhodecode.lib import caches | |
43 | from rhodecode.lib.auth import AuthUser, HasPermissionAnyMiddleware |
|
43 | from rhodecode.lib.auth import AuthUser, HasPermissionAnyMiddleware | |
44 | from rhodecode.lib.base import ( |
|
44 | from rhodecode.lib.base import ( | |
@@ -360,6 +360,14 b' class SimpleVCS(object):' | |||||
360 | return False |
|
360 | return False | |
361 | return True |
|
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 | def __call__(self, environ, start_response): |
|
371 | def __call__(self, environ, start_response): | |
364 | try: |
|
372 | try: | |
365 | return self._handle_request(environ, start_response) |
|
373 | return self._handle_request(environ, start_response) | |
@@ -419,9 +427,13 b' class SimpleVCS(object):' | |||||
419 | anonymous_user = User.get_default_user() |
|
427 | anonymous_user = User.get_default_user() | |
420 | username = anonymous_user.username |
|
428 | username = anonymous_user.username | |
421 | if anonymous_user.active: |
|
429 | if anonymous_user.active: | |
|
430 | plugin_cache_active, cache_ttl = self._get_default_cache_ttl() | |||
422 | # ONLY check permissions if the user is activated |
|
431 | # ONLY check permissions if the user is activated | |
423 | anonymous_perm = self._check_permission( |
|
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 | else: |
|
437 | else: | |
426 | anonymous_perm = False |
|
438 | anonymous_perm = False | |
427 |
|
439 |
@@ -229,6 +229,9 b' class TestShadowRepoExposure(object):' | |||||
229 | controller._action = 'pull' |
|
229 | controller._action = 'pull' | |
230 | controller._is_shadow_repo_dir = True |
|
230 | controller._is_shadow_repo_dir = True | |
231 | controller.stub_response_body = 'dummy body value' |
|
231 | controller.stub_response_body = 'dummy body value' | |
|
232 | controller._get_default_cache_ttl = mock.Mock( | |||
|
233 | return_value=(False, 0)) | |||
|
234 | ||||
232 | environ_stub = { |
|
235 | environ_stub = { | |
233 | 'HTTP_HOST': 'test.example.com', |
|
236 | 'HTTP_HOST': 'test.example.com', | |
234 | 'HTTP_ACCEPT': 'application/mercurial', |
|
237 | 'HTTP_ACCEPT': 'application/mercurial', |
General Comments 0
You need to be logged in to leave comments.
Login now