浏览代码

Revert "ldap auth: remove unused code"

Bastien Sevajol 9 年前
父节点
当前提交
a17ecaa0ce
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. 11 1
      tracim/tracim/lib/auth/ldap.py

+ 11 - 1
tracim/tracim/lib/auth/ldap.py 查看文件

37
         self._config['sa_auth'].authmetadata = LDAPApplicationAuthMetadata(self._config.get('sa_auth'))
37
         self._config['sa_auth'].authmetadata = LDAPApplicationAuthMetadata(self._config.get('sa_auth'))
38
 
38
 
39
     def _get_ldap_auth(self):
39
     def _get_ldap_auth(self):
40
-        return LDAPSearchAuthenticatorPlugin(
40
+        auth_plug = LDAPSearchAuthenticatorPlugin(
41
             url=self._config.get('ldap_url'),
41
             url=self._config.get('ldap_url'),
42
             base_dn=self._config.get('ldap_base_dn'),
42
             base_dn=self._config.get('ldap_base_dn'),
43
             bind_dn=self._config.get('ldap_bind_dn'),
43
             bind_dn=self._config.get('ldap_bind_dn'),
47
             naming_attribute=self._config.get('ldap_naming_attribute'),
47
             naming_attribute=self._config.get('ldap_naming_attribute'),
48
             start_tls=ini_conf_to_bool(self._config.get('ldap_tls', False)),
48
             start_tls=ini_conf_to_bool(self._config.get('ldap_tls', False)),
49
         )
49
         )
50
+        auth_plug.set_auth(self)
51
+        return auth_plug
50
 
52
 
51
     def _get_ldap_user_provider(self):
53
     def _get_ldap_user_provider(self):
52
         return LDAPAttributesPlugin(
54
         return LDAPAttributesPlugin(
74
 
76
 
75
 class LDAPSearchAuthenticatorPlugin(BaseLDAPSearchAuthenticatorPlugin):
77
 class LDAPSearchAuthenticatorPlugin(BaseLDAPSearchAuthenticatorPlugin):
76
 
78
 
79
+    def __init__(self, *args, **kwargs):
80
+        super().__init__(*args, **kwargs)
81
+        self._auth = None
82
+        self._user_api = UserApi(None)
83
+
84
+    def set_auth(self, auth):
85
+        self._auth = auth
86
+
77
     def authenticate(self, environ, identity):
87
     def authenticate(self, environ, identity):
78
         # Note: super().authenticate return None if already authenticated or not found
88
         # Note: super().authenticate return None if already authenticated or not found
79
         email = super().authenticate(environ, identity)
89
         email = super().authenticate(environ, identity)