Show More
@@ -578,14 +578,20 b' def get_authn_registry(registry=None):' | |||||
578 | return authn_registry |
|
578 | return authn_registry | |
579 |
|
579 | |||
580 |
|
580 | |||
581 | def get_auth_cache_manager(custom_ttl=None): |
|
581 | def get_auth_cache_manager(custom_ttl=None, suffix=None): | |
|
582 | cache_name = 'rhodecode.authentication' | |||
|
583 | if suffix: | |||
|
584 | cache_name = 'rhodecode.authentication.{}'.format(suffix) | |||
582 | return caches.get_cache_manager( |
|
585 | return caches.get_cache_manager( | |
583 |
'auth_plugins', |
|
586 | 'auth_plugins', cache_name, custom_ttl) | |
584 |
|
587 | |||
585 |
|
588 | |||
586 | def get_perms_cache_manager(custom_ttl=None): |
|
589 | def get_perms_cache_manager(custom_ttl=None, suffix=None): | |
|
590 | cache_name = 'rhodecode.permissions' | |||
|
591 | if suffix: | |||
|
592 | cache_name = 'rhodecode.permissions.{}'.format(suffix) | |||
587 | return caches.get_cache_manager( |
|
593 | return caches.get_cache_manager( | |
588 |
'auth_plugins', |
|
594 | 'auth_plugins', cache_name, custom_ttl) | |
589 |
|
595 | |||
590 |
|
596 | |||
591 | def authenticate(username, password, environ=None, auth_type=None, |
|
597 | def authenticate(username, password, environ=None, auth_type=None, | |
@@ -646,7 +652,8 b' def authenticate(username, password, env' | |||||
646 | plugin_cache_active, cache_ttl = plugin.get_ttl_cache(plugin_settings) |
|
652 | plugin_cache_active, cache_ttl = plugin.get_ttl_cache(plugin_settings) | |
647 |
|
653 | |||
648 | # get instance of cache manager configured for a namespace |
|
654 | # get instance of cache manager configured for a namespace | |
649 |
cache_manager = get_auth_cache_manager( |
|
655 | cache_manager = get_auth_cache_manager( | |
|
656 | custom_ttl=cache_ttl, suffix=user.user_id) | |||
650 |
|
657 | |||
651 | log.debug('AUTH_CACHE_TTL for plugin `%s` active: %s (TTL: %s)', |
|
658 | log.debug('AUTH_CACHE_TTL for plugin `%s` active: %s (TTL: %s)', | |
652 | plugin.get_id(), plugin_cache_active, cache_ttl) |
|
659 | plugin.get_id(), plugin_cache_active, cache_ttl) |
@@ -32,6 +32,7 b' from rhodecode.authentication.base impor' | |||||
32 | from rhodecode.lib import helpers as h |
|
32 | from rhodecode.lib import helpers as h | |
33 | from rhodecode.lib.auth import ( |
|
33 | from rhodecode.lib.auth import ( | |
34 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) |
|
34 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) | |
|
35 | from rhodecode.lib.caches import clear_cache_manager | |||
35 | from rhodecode.model.forms import AuthSettingsForm |
|
36 | from rhodecode.model.forms import AuthSettingsForm | |
36 | from rhodecode.model.meta import Session |
|
37 | from rhodecode.model.meta import Session | |
37 | from rhodecode.model.settings import SettingsModel |
|
38 | from rhodecode.model.settings import SettingsModel | |
@@ -101,6 +102,16 b' class AuthnPluginViewBase(BaseAppView):' | |||||
101 | self.plugin.create_or_update_setting(name, value) |
|
102 | self.plugin.create_or_update_setting(name, value) | |
102 | Session().commit() |
|
103 | Session().commit() | |
103 |
|
104 | |||
|
105 | # cleanup cache managers in case of change for plugin | |||
|
106 | # TODO(marcink): because we can register multiple namespaces | |||
|
107 | # we should at some point figure out how to retrieve ALL namespace | |||
|
108 | # cache managers and clear them... | |||
|
109 | cache_manager = get_auth_cache_manager() | |||
|
110 | clear_cache_manager(cache_manager) | |||
|
111 | ||||
|
112 | cache_manager = get_perms_cache_manager() | |||
|
113 | clear_cache_manager(cache_manager) | |||
|
114 | ||||
104 | # Display success message and redirect. |
|
115 | # Display success message and redirect. | |
105 | h.flash(_('Auth settings updated successfully.'), category='success') |
|
116 | h.flash(_('Auth settings updated successfully.'), category='success') | |
106 | redirect_to = self.request.resource_path( |
|
117 | redirect_to = self.request.resource_path( | |
@@ -161,12 +172,6 b' class AuthSettingsView(BaseAppView):' | |||||
161 | Session().add(setting) |
|
172 | Session().add(setting) | |
162 | Session().commit() |
|
173 | Session().commit() | |
163 |
|
174 | |||
164 | cache_manager = get_auth_cache_manager() |
|
|||
165 | cache_manager.clear() |
|
|||
166 |
|
||||
167 | cache_manager = get_perms_cache_manager() |
|
|||
168 | cache_manager.clear() |
|
|||
169 |
|
||||
170 | h.flash(_('Auth settings updated successfully.'), category='success') |
|
175 | h.flash(_('Auth settings updated successfully.'), category='success') | |
171 | except formencode.Invalid as errors: |
|
176 | except formencode.Invalid as errors: | |
172 | e = errors.error_dict or {} |
|
177 | e = errors.error_dict or {} |
@@ -288,7 +288,8 b' class SimpleVCS(object):' | |||||
288 | """ |
|
288 | """ | |
289 |
|
289 | |||
290 | # get instance of cache manager configured for a namespace |
|
290 | # get instance of cache manager configured for a namespace | |
291 |
cache_manager = get_perms_cache_manager( |
|
291 | cache_manager = get_perms_cache_manager( | |
|
292 | custom_ttl=cache_ttl, suffix=user.user_id) | |||
292 | log.debug('AUTH_CACHE_TTL for permissions `%s` active: %s (TTL: %s)', |
|
293 | log.debug('AUTH_CACHE_TTL for permissions `%s` active: %s (TTL: %s)', | |
293 | plugin_id, plugin_cache_active, cache_ttl) |
|
294 | plugin_id, plugin_cache_active, cache_ttl) | |
294 |
|
295 |
General Comments 0
You need to be logged in to leave comments.
Login now