blob: 497a9b3aba2c2c6cebde0070895adafa9f8ecc0a [file] [log] [blame]
Akronca9bd982016-12-06 16:59:57 +01001import logging
2
3from APIFactory import URIBuilder
4
5from types import *
6from notifications import *
7from utils import *
8
9
10__author__ = 'hanl'
11
12# instance reference for authentication provider
13# must be set before usage!
14PROVIDER = None
15
16
17def init_app(config):
18 provider_name = config.get('AUTH_PROVIDER', 'providers.CustomProvider')
19 split = provider_name.split('.')
20 # get last element, so you have the class name
21 _class = split[len(split) - 1]
22
23 provider_name = provider_name.replace("." + _class, "")
24 module = __import__(provider_name)
25 obj = getattr(module, _class, None)
26 if obj is None:
27 raise KeyError("the provider class '%s.%s' is undefined or could not be found!" % (provider_name, _class))
28 instance = obj(config)
29 logging.info("successfully loaded provider '%s.%s'" % (provider_name, _class))
30 global PROVIDER
31 PROVIDER = instance
32