当前位置: 首页>>代码示例>>Python>>正文


Python PolicyClass.get_auth_challenge_response方法代码示例

本文整理汇总了Python中privacyidea.lib.policy.PolicyClass.get_auth_challenge_response方法的典型用法代码示例。如果您正苦于以下问题:Python PolicyClass.get_auth_challenge_response方法的具体用法?Python PolicyClass.get_auth_challenge_response怎么用?Python PolicyClass.get_auth_challenge_response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在privacyidea.lib.policy.PolicyClass的用法示例。


在下文中一共展示了PolicyClass.get_auth_challenge_response方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_standard

# 需要导入模块: from privacyidea.lib.policy import PolicyClass [as 别名]
# 或者: from privacyidea.lib.policy.PolicyClass import get_auth_challenge_response [as 别名]
    def check_standard(self, passw, user, options=None):
        '''
        do a standard verification, as we are not in a challengeResponse mode

        the upper interfaces expect in the success the otp counter or at
        least 0 if we have a success. A -1 identifies an error

        :param passw: the password, which should be checked
        :param options: dict with additional request parameters

        :return: tuple of matching otpcounter and a potential reply
        '''

        otp_count = -1
        pin_match = False
        reply = None

        ttype = self.token.getType()

        ## fallback eg. in case of check_s, which does not provide a user
        if user is None:
            user = privacyidea.lib.token.get_token_owner(self.token)
            
        Policy = PolicyClass(request, config, c,
                             get_privacyIDEA_config())
        support_challenge_response = Policy.get_auth_challenge_response(user, ttype)

        ## special handling for tokens, who support only challenge modes
        ## like the sms, email or ocra2 token
        challenge_mode_only = False

        mode = self.token.mode
        if type(mode) == list and len(mode) == 1 and mode[0] == "challenge":
            challenge_mode_only = True

        ## the support_challenge_response is overruled, if the token
        ## supports only challenge processing
        if challenge_mode_only == True:
            support_challenge_response = True

        try:
            ## call the token authentication
            (pin_match, otp_count, reply) = self.token.authenticate(passw, user,
                                                                options=options)
        except Exception as exx:
            if (support_challenge_response == True and
                self.token.is_challenge_request(passw, user, options=options)):
                LOG.info("Retry on base of a challenge request:")
                pin_match = False
                otp_count = -1
            else:
                LOG.error("%s" % (traceback.format_exc()))
                raise Exception(exx)

        if otp_count < 0 or pin_match == False:

            if (support_challenge_response == True and
                self.token.isActive() and
                self.token.is_challenge_request(passw, user, options=options)):
                # we are in createChallenge mode
                # fix for #12413:
                # - moved the create_challenge call to the checkTokenList!
                ## after all tokens are processed and only one is challengeing
                # (_res, reply) = create_challenge(self.token, options=options)
                self.challenge_token.append(self.token)

        if len(self.challenge_token) == 0:
            if otp_count >= 0:
                self.valid_token.append(self.token)
            elif pin_match is True:
                self.pin_matching_token.append(self.token)
            else:
                self.invalid_token.append(self.token)

        return (otp_count, reply)
开发者ID:asifiqbal,项目名称:privacyidea,代码行数:77,代码来源:validate.py


注:本文中的privacyidea.lib.policy.PolicyClass.get_auth_challenge_response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。