]> git.openstreetmap.org Git - osqa.git/blob - forum/authentication/__init__.py
Remove footer link to squatted domain
[osqa.git] / forum / authentication / __init__.py
1 import re
2 import django.dispatch
3 from forum.modules import get_modules_script_classes
4 from forum.authentication.base import AuthenticationConsumer, ConsumerTemplateContext
5
6 class ConsumerAndContext:
7     def __init__(self, id, consumer, context):
8         self.id = id
9         self._consumer = consumer
10
11         if context:
12             context.id = id
13         self.context = context
14
15     @property
16     def consumer(self):
17         return self._consumer()
18
19 consumers = dict([
20             (re.sub('AuthConsumer$', '', name).lower(), cls) for name, cls
21             in get_modules_script_classes('authentication', AuthenticationConsumer).items()
22             if not re.search('AbstractAuthConsumer$', name)
23         ])
24
25 contexts = dict([
26             (re.sub('AuthContext$', '', name).lower(), cls) for name, cls
27             in get_modules_script_classes('authentication', ConsumerTemplateContext).items()
28         ])
29
30 AUTH_PROVIDERS = dict([
31             (name, ConsumerAndContext(name, consumers[name], contexts.get(name, None))) for name in consumers.keys()
32         ])
33
34