Bastien Sevajol 9 лет назад
Родитель
Сommit
1a0e9a768e

+ 6 - 6
tracim/tracim/config/__init__.py Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2
-from tg import AppConfig, config
2
+from tg import AppConfig
3 3
 
4 4
 from tracim.lib.auth.wrapper import AuthConfigWrapper
5 5
 
@@ -10,10 +10,10 @@ class TracimAppConfig(AppConfig):
10 10
     """
11 11
 
12 12
     def after_init_config(self, conf):
13
-        self._set_up_auth()
14
-        # Fix an tg2 strange thing: auth_backend is set in config, but instance
13
+        self._set_up_auth(conf)
14
+        #  Fix an tg2 strange thing: auth_backend is set in config, but instance
15 15
         #  of AppConfig has None in auth_backend attr
16
-        self.auth_backend = config.auth_backend
16
+        self.auth_backend = conf['auth_backend']
17 17
 
18
-    def _set_up_auth(self, ):
19
-        AuthConfigWrapper.wrap(config)
18
+    def _set_up_auth(self, conf):
19
+        AuthConfigWrapper.wrap(conf)

+ 3 - 3
tracim/tracim/lib/auth/base.py Просмотреть файл

@@ -11,12 +11,12 @@ class Auth:
11 11
     def wrap_config(self):
12 12
         # override this if you would like to provide a different who plugin for
13 13
         # managing login and logout of your application
14
-        self._config.sa_auth.form_plugin = None
14
+        self._config['sa_auth'].form_plugin = None
15 15
 
16 16
         # You may optionally define a page where you want users to be redirected to
17 17
         # on login:
18
-        self._config.sa_auth.post_login_url = '/post_login'
18
+        self._config['sa_auth'].post_login_url = '/post_login'
19 19
 
20 20
         # You may optionally define a page where you want users to be redirected to
21 21
         # on logout:
22
-        self._config.sa_auth.post_logout_url = '/post_logout'
22
+        self._config['sa_auth'].post_logout_url = '/post_logout'

+ 4 - 4
tracim/tracim/lib/auth/internal.py Просмотреть файл

@@ -13,10 +13,10 @@ class InternalAuth(Auth):
13 13
     def wrap_config(self):
14 14
         super().wrap_config()
15 15
 
16
-        self._config.sa_auth.user_class = User
17
-        self._config.auth_backend = 'sqlalchemy'
18
-        self._config.sa_auth.dbsession = DBSession
19
-        self._config.sa_auth.authmetadata = InternalApplicationAuthMetadata(self._config.sa_auth)
16
+        self._config['sa_auth'].user_class = User
17
+        self._config['auth_backend'] = 'sqlalchemy'
18
+        self._config['sa_auth'].dbsession = DBSession
19
+        self._config['sa_auth'].authmetadata = InternalApplicationAuthMetadata(self._config.get('sa_auth'))
20 20
 
21 21
 
22 22
 class InternalApplicationAuthMetadata(TGAuthMetadata):

+ 4 - 4
tracim/tracim/lib/auth/ldap.py Просмотреть файл

@@ -26,15 +26,15 @@ class LDAPAuth(Auth):
26 26
 
27 27
     def wrap_config(self):
28 28
         super().wrap_config()
29
-        self._config.auth_backend = 'ldapauth'
30
-        self._config.sa_auth.authenticators = [('ldapauth', self.ldap_auth)]
29
+        self._config['auth_backend'] = 'ldapauth'
30
+        self._config['sa_auth'].authenticators = [('ldapauth', self.ldap_auth)]
31 31
 
32 32
         mdproviders = [('ldapuser', self.ldap_user_provider)]
33 33
         if self._config.get('ldap_group_enabled', False):
34 34
             mdproviders.append(('ldapgroups', self.ldap_groups_provider))
35
-        self._config.sa_auth.mdproviders = mdproviders
35
+        self._config['sa_auth'].mdproviders = mdproviders
36 36
 
37
-        self._config.sa_auth.authmetadata = LDAPApplicationAuthMetadata(self._config.sa_auth)
37
+        self._config['sa_auth'].authmetadata = LDAPApplicationAuthMetadata(self._config.get('sa_auth'))
38 38
 
39 39
     def _get_ldap_auth(self):
40 40
         auth_plug = LDAPSearchAuthenticatorPlugin(

+ 2 - 2
tracim/tracim/lib/auth/wrapper.py Просмотреть файл

@@ -21,6 +21,6 @@ class AuthConfigWrapper:
21 21
         for wrapper_class in cls.AUTH_WRAPPERS:
22 22
             if wrapper_class.name is NotImplemented:
23 23
                 raise Exception("\"name\" attribute of %s is required" % str(wrapper_class))
24
-            if config.auth_type == wrapper_class.name:
24
+            if config.get('auth_type') == wrapper_class.name:
25 25
                 return wrapper_class
26
-        raise Exception("No auth config wrapper found for \"%s\" auth_type config" % config.auth_type)
26
+        raise Exception("No auth config wrapper found for \"%s\" auth_type config" % config.get('auth_type'))