本文整理汇总了Python中oic.utils.authn.authn_context.AuthnBroker.pick方法的典型用法代码示例。如果您正苦于以下问题:Python AuthnBroker.pick方法的具体用法?Python AuthnBroker.pick怎么用?Python AuthnBroker.pick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oic.utils.authn.authn_context.AuthnBroker
的用法示例。
在下文中一共展示了AuthnBroker.pick方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from oic.utils.authn.authn_context import AuthnBroker [as 别名]
# 或者: from oic.utils.authn.authn_context.AuthnBroker import pick [as 别名]
def test(self):
ac = AuthnBroker()
issuer = "https://example.com/op"
CAS_SERVER = ""
SERVICE_URL = ""
LDAP = {
"uri": "ldaps://ldap.umu.se",
"base": "dc=umu, dc=se",
"filter_pattern": "(uid=%s)",
"user": "",
"passwd": "",
"attr": ["eduPersonScopedAffiliation", "eduPersonAffiliation"],
}
LDAP_EXTRAVALIDATION = {
"verify_attr": "eduPersonAffiliation",
"verify_attr_valid": ['employee', 'staff', 'student']
}
LDAP_EXTRAVALIDATION.update(LDAP)
ac.add(PASSWORD,
UsernamePasswordMako(None, "login.mako", LOOKUP, PASSWD,
"%s/authorization" % issuer),
10, "http://%s" % socket.gethostname())
try:
ac.add(PASSWORD,
CasAuthnMethod(
None, CAS_SERVER, SERVICE_URL,
"%s/authorization" % issuer,
UserLDAPMemberValidation(**LDAP_EXTRAVALIDATION)),
20, "http://%s" % socket.gethostname())
except Exception:
assert len(ac) == 1
else:
assert len(ac) == 2
res = ac.pick(PASSWORD)
assert res
# list of two 2-tuples
assert len(res) == 2
assert res[0][0].__class__.__name__ == "CasAuthnMethod"
assert res[1][0].__class__.__name__ == "UsernamePasswordMako"