functions.authenticate 在支持不同的鉴权类型的时候的问题

3 views
Skip to first unread message

Chunlin Zhang

unread,
Apr 12, 2016, 6:42:50 AM4/12/16
to uli...@googlegroups.com
关于 functions.authenticate 在支持不同的鉴权类型的时候要怎么处理, 比如说同时支持ldap和内建用户,那这个接口要怎么同时支持这两种呢?
因为需要同时支持不同的验证方式,那么是不是需要加上 auth_type 参数,然后不同的auth_type注册不同的 authenticate 函数,然后由 functions.authenticate 去调用呢?
当然像社交帐号登入等方式没办法和这种方式兼容就不考虑了.

Chunlin Zhang

unread,
Apr 13, 2016, 8:17:39 AM4/13/16
to uli...@googlegroups.com
我想了个办法,在某个auth type的属性里加一个authenticate用于注册此auth type的authenticate函数
[AUTH]
#user from ldap
AUTH_TYPE_LDAP = 100
AUTH_TYPE = [(100, {'type':'ldap','authenticate':'shapps.auth.ldap.authenticate'}})]
之后再写一个 get_authenticate 供调用,可以从auth_type查到authenticate函数

Chunlin Zhang

unread,
Apr 15, 2016, 2:35:58 AM4/15/16
to uli...@googlegroups.com
https://github.com/limodou/uliweb/pull/65
换了想法,将 authenticate 改成尝试各种auth_type的authenticate的方式
Reply all
Reply to author
Forward
0 new messages