Show More
@@ -490,13 +490,19 b' def loadplugin(plugin_id):' | |||
|
490 | 490 | or None on failure. |
|
491 | 491 | """ |
|
492 | 492 | # TODO: Disusing pyramids thread locals to retrieve the registry. |
|
493 |
authn_registry = get_ |
|
|
493 | authn_registry = get_authn_registry() | |
|
494 | 494 | plugin = authn_registry.get_plugin(plugin_id) |
|
495 | 495 | if plugin is None: |
|
496 | 496 | log.error('Authentication plugin not found: "%s"', plugin_id) |
|
497 | 497 | return plugin |
|
498 | 498 | |
|
499 | 499 | |
|
500 | def get_authn_registry(registry=None): | |
|
501 | registry = registry or get_current_registry() | |
|
502 | authn_registry = registry.getUtility(IAuthnPluginRegistry) | |
|
503 | return authn_registry | |
|
504 | ||
|
505 | ||
|
500 | 506 | def get_auth_cache_manager(custom_ttl=None): |
|
501 | 507 | return caches.get_cache_manager( |
|
502 | 508 | 'auth_plugins', 'rhodecode.authentication', custom_ttl) |
@@ -520,7 +526,7 b' def authenticate(username, password, env' | |||
|
520 | 526 | % auth_type) |
|
521 | 527 | headers_only = environ and not (username and password) |
|
522 | 528 | |
|
523 |
authn_registry = get_ |
|
|
529 | authn_registry = get_authn_registry() | |
|
524 | 530 | for plugin in authn_registry.get_plugins_for_authentication(): |
|
525 | 531 | plugin.set_auth_type(auth_type) |
|
526 | 532 | user = plugin.get_user(username) |
@@ -83,13 +83,17 b' class RhodeCodeAuthPlugin(RhodeCodeAuthP' | |||
|
83 | 83 | allowed_auth_plugins=None, allowed_auth_sources=None): |
|
84 | 84 | """ |
|
85 | 85 | Custom method for this auth that doesn't accept empty users. And also |
|
86 | allows rhodecode and authtoken extern_type to auth with this. But only | |
|
87 | via vcs mode | |
|
86 | allows users from all other active plugins to use it and also | |
|
87 | authenticate against it. But only via vcs mode | |
|
88 | 88 | """ |
|
89 | # only this and rhodecode plugins can use this type | |
|
90 | from rhodecode.authentication.plugins import auth_rhodecode | |
|
91 | allowed_auth_plugins = [ | |
|
92 | self.name, auth_rhodecode.RhodeCodeAuthPlugin.name] | |
|
89 | from rhodecode.authentication.base import get_authn_registry | |
|
90 | authn_registry = get_authn_registry() | |
|
91 | ||
|
92 | active_plugins = set( | |
|
93 | [x.name for x in authn_registry.get_plugins_for_authentication()]) | |
|
94 | active_plugins.discard(self.name) | |
|
95 | ||
|
96 | allowed_auth_plugins = [self.name] + list(active_plugins) | |
|
93 | 97 | # only for vcs operations |
|
94 | 98 | allowed_auth_sources = [VCS_TYPE] |
|
95 | 99 |
@@ -26,8 +26,8 b' from pyramid.httpexceptions import HTTPF' | |||
|
26 | 26 | from pyramid.renderers import render |
|
27 | 27 | from pyramid.response import Response |
|
28 | 28 | |
|
29 |
from rhodecode.authentication.base import |
|
|
30 | from rhodecode.authentication.interface import IAuthnPluginRegistry | |
|
29 | from rhodecode.authentication.base import ( | |
|
30 | get_auth_cache_manager, get_authn_registry) | |
|
31 | 31 | from rhodecode.lib import auth |
|
32 | 32 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator |
|
33 | 33 | from rhodecode.model.forms import AuthSettingsForm |
@@ -125,7 +125,7 b' class AuthSettingsView(object):' | |||
|
125 | 125 | @HasPermissionAllDecorator('hg.admin') |
|
126 | 126 | def index(self, defaults=None, errors=None, prefix_error=False): |
|
127 | 127 | defaults = defaults or {} |
|
128 |
authn_registry = self.request.registry |
|
|
128 | authn_registry = get_authn_registry(self.request.registry) | |
|
129 | 129 | enabled_plugins = SettingsModel().get_auth_plugins() |
|
130 | 130 | |
|
131 | 131 | # Create template context and render it. |
General Comments 0
You need to be logged in to leave comments.
Login now