本文整理汇总了Python中privacyidea.lib.policy.PolicyClass.get_pin_policies方法的典型用法代码示例。如果您正苦于以下问题:Python PolicyClass.get_pin_policies方法的具体用法?Python PolicyClass.get_pin_policies怎么用?Python PolicyClass.get_pin_policies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类privacyidea.lib.policy.PolicyClass
的用法示例。
在下文中一共展示了PolicyClass.get_pin_policies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: split_pin_otp
# 需要导入模块: from privacyidea.lib.policy import PolicyClass [as 别名]
# 或者: from privacyidea.lib.policy.PolicyClass import get_pin_policies [as 别名]
def split_pin_otp(token, passw, user=None, options=None):
'''
split the pin and the otp fron the given password
:param passw: the to be splitted password
:param options: currently not used, but might be forwarded to the
token.splitPinPass
:return: tuple of (split status, pin and otpval)
'''
Policy = PolicyClass(request, config, c,
get_privacyIDEA_config())
pin_policies = Policy.get_pin_policies(user)
policy = 0
if 1 in pin_policies:
LOG.debug("pin policy=1: checking the users password as pin")
# split the passw into password and otp value
(res, pin, otp) = token.splitPinPass(passw)
policy = 1
elif 2 in pin_policies:
# NO PIN should be entered atall
LOG.debug("pin policy=2: checking no pin")
(res, pin, otp) = (0, "", passw)
policy = 2
else:
# old stuff: We check The fixed OTP PIN
LOG.debug("pin policy=0: checkin the PIN")
(res, pin, otp) = token.splitPinPass(passw)
if res != -1:
res = policy
return (res, pin, otp)
示例2: check_pin
# 需要导入模块: from privacyidea.lib.policy import PolicyClass [as 别名]
# 或者: from privacyidea.lib.policy.PolicyClass import get_pin_policies [as 别名]
def check_pin(token, passw, user=None, options=None):
'''
check the provided pin w.r.t. the policy definition
:param passw: the to be checked pass
:param user: if otppin==1, this is the user, which resolver should
be checked
:param options: the optional request parameters
:return: boolean, if pin matched True
'''
res = False
Policy = PolicyClass(request, config, c,
get_privacyIDEA_config())
pin_policies = Policy.get_pin_policies(user)
if 1 in pin_policies:
# We check the Users Password as PIN
LOG.debug("pin policy=1: checking the users"
" password as pin")
if (user is None):
raise Exception("fail for pin policy == 1 with user = None")
(uid, _resolver, resolver_class) = getUserId(user)
r_obj = getResolverObject(resolver_class)
if r_obj.checkPass(uid, passw):
LOG.debug("Successfully authenticated user %r." % uid)
res = True
else:
LOG.info("user %r failed to authenticate." % uid)
elif 2 in pin_policies:
# NO PIN should be entered atall
LOG.debug("pin policy=2: checking no pin")
if len(passw) == 0:
res = True
else:
# old stuff: We check The fixed OTP PIN
LOG.debug("pin policy=0: checkin the PIN")
res = token.checkPin(passw, options=options)
return res