mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Move init_authenticator to actionsmap.py for clarity to avoid spreading this shit over 72 files
This commit is contained in:
parent
65fe685a90
commit
ebc37ea014
2 changed files with 10 additions and 22 deletions
|
@ -7,9 +7,9 @@ import yaml
|
|||
import cPickle as pickle
|
||||
from time import time
|
||||
from collections import OrderedDict
|
||||
from importlib import import_module
|
||||
|
||||
from moulinette import m18n, msignals
|
||||
from moulinette.core import init_authenticator
|
||||
from moulinette.cache import open_cachefile
|
||||
from moulinette.globals import init_moulinette_env
|
||||
from moulinette.core import (MoulinetteError, MoulinetteLock)
|
||||
|
@ -445,12 +445,20 @@ class ActionsMap(object):
|
|||
|
||||
def get_authenticator_for_profile(self, auth_profile):
|
||||
|
||||
# Fetch the configuration for the authenticator module as defined in the actionmap
|
||||
try:
|
||||
auth_conf = self.parser.global_conf['authenticator'][auth_profile]
|
||||
except KeyError:
|
||||
raise ValueError("Unknown authenticator profile '%s'" % auth_profile)
|
||||
|
||||
return init_authenticator(auth_conf)
|
||||
# Load and initialize the authenticator module
|
||||
try:
|
||||
mod = import_module('moulinette.authenticators.%s' % auth_conf["vendor"])
|
||||
except ImportError:
|
||||
logger.exception("unable to load authenticator vendor '%s'", auth_conf["vendor"])
|
||||
raise MoulinetteError('error_see_log')
|
||||
else:
|
||||
return mod.Authenticator(**auth_conf)
|
||||
|
||||
def check_authentication_if_required(self, args, **kwargs):
|
||||
|
||||
|
|
|
@ -396,26 +396,6 @@ def init_interface(name, kwargs={}, actionsmap={}):
|
|||
return interface(amap, **kwargs)
|
||||
|
||||
|
||||
def init_authenticator(auth_conf):
|
||||
"""Return a new authenticator instance
|
||||
|
||||
Retrieve the given authenticator vendor and return a new instance of
|
||||
its Authenticator class for the given profile.
|
||||
|
||||
Keyword arguments:
|
||||
- vendor -- The authenticator vendor name
|
||||
- name -- The authenticator profile name
|
||||
- kwargs -- A dict of arguments for the authenticator profile
|
||||
|
||||
"""
|
||||
try:
|
||||
mod = import_module('moulinette.authenticators.%s' % auth_conf["vendor"])
|
||||
except ImportError:
|
||||
logger.exception("unable to load authenticator vendor '%s'", auth_conf["vendor"])
|
||||
raise MoulinetteError('error_see_log')
|
||||
else:
|
||||
return mod.Authenticator(**auth_conf)
|
||||
|
||||
def clean_session(session_id, profiles=[]):
|
||||
"""Clean a session cache
|
||||
|
||||
|
|
Loading…
Reference in a new issue