Bastien Sevajol 9 年前
父节点
当前提交
fb4c9c3fc8
共有 2 个文件被更改,包括 16 次插入3 次删除
  1. 12 3
      tracim/tracim/lib/auth/base.py
  2. 4 0
      tracim/tracim/lib/auth/internal.py

+ 12 - 3
tracim/tracim/lib/auth/base.py 查看文件

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 from tg.util import Bunch
2
 from tg.util import Bunch
3
 
3
 
4
+""" Backup of config.sa_auth """
4
 _original_sa_auth = None
5
 _original_sa_auth = None
5
 
6
 
6
 
7
 
7
 def _get_clean_sa_auth(config):
8
 def _get_clean_sa_auth(config):
8
     """
9
     """
9
-    TODO COMMENT
10
-    :param config:
11
-    :return:
10
+    Return the original sa_auth parameter. Consider Original as it's content before first fill in configuration.
11
+    :param config: tg2 app config
12
+    :return: original sa_auth parameter
12
     """
13
     """
13
     global _original_sa_auth
14
     global _original_sa_auth
14
 
15
 
21
 
22
 
22
 
23
 
23
 class Auth:
24
 class Auth:
25
+    """
26
+    Auth strategy base class
27
+    """
24
 
28
 
29
+    """ Auth strategy must be named: .ini config will use this name in auth_type parameter """
25
     name = NotImplemented
30
     name = NotImplemented
26
 
31
 
27
     def __init__(self, config):
32
     def __init__(self, config):
28
         self._config = config
33
         self._config = config
29
 
34
 
30
     def wrap_config(self):
35
     def wrap_config(self):
36
+        """
37
+        Fill config with auth needed. You must overload with whild implementation.
38
+        :return:
39
+        """
31
         self._config['sa_auth'] = _get_clean_sa_auth(self._config)
40
         self._config['sa_auth'] = _get_clean_sa_auth(self._config)
32
 
41
 
33
         # override this if you would like to provide a different who plugin for
42
         # override this if you would like to provide a different who plugin for

+ 4 - 0
tracim/tracim/lib/auth/internal.py 查看文件

11
     name = 'internal'
11
     name = 'internal'
12
 
12
 
13
     def wrap_config(self):
13
     def wrap_config(self):
14
+        """
15
+        Fill config with internal (database) auth information.
16
+        :return:
17
+        """
14
         super().wrap_config()
18
         super().wrap_config()
15
 
19
 
16
         self._config['sa_auth'].user_class = User
20
         self._config['sa_auth'].user_class = User