authn: Import legacy authentication modules and invoke their includeme.
This commit is contained in:
parent
6868abc1b7
commit
a8d92f8858
1 changed files with 14 additions and 1 deletions
|
|
@ -19,6 +19,7 @@
|
|||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
import logging
|
||||
import importlib
|
||||
|
||||
from pkg_resources import iter_entry_points
|
||||
from pyramid.authentication import SessionAuthenticationPolicy
|
||||
|
|
@ -56,9 +57,21 @@ def _discover_legacy_plugins(config, prefix='py:'):
|
|||
enabled_plugins = auth_plugins.app_settings_value
|
||||
legacy_plugins = [id_ for id_ in enabled_plugins if id_.startswith(prefix)]
|
||||
|
||||
log.debug('Trying to load these legacy authentication plugins {}'.format(
|
||||
log.debug('Importing these legacy authentication plugins {}'.format(
|
||||
legacy_plugins))
|
||||
|
||||
for plugin_id in legacy_plugins:
|
||||
module_name = plugin_id.split(prefix, 1)[-1]
|
||||
try:
|
||||
log.debug('Import %s', module_name)
|
||||
module = importlib.import_module(module_name)
|
||||
plugin = module.plugin_factory(plugin_id=plugin_id)
|
||||
config.include(plugin.includeme)
|
||||
except ImportError as e:
|
||||
log.error(
|
||||
'Error while importing legacy authentication plugin '
|
||||
'"{}": {}'.format(plugin_id, e.message))
|
||||
|
||||
|
||||
def includeme(config):
|
||||
# Set authentication policy.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue