def checkResponse4Challenge(self, user, passw, options=None, challenges=None): ''' verify the response of a previous challenge :param user: the requesting user :param passw: the to be checked pass (pin+otp) :param options: options an additional argument, which could be token specific :param challenges: the list of challenges, where each challenge is described as dict :return: tuple of (otpcounter and the list of matching challenges) ''' otp_counter = -1 transid = None matching = None matchin_challenges = [] if 'transactionid' in options or 'state' in options: ## fetch the transactionid transid = options.get('transactionid', options.get('state', None)) # check if the transactionid is in the list of challenges if transid is not None: for challenge in challenges: if is_same_transaction(challenge, transid): matching = challenge break if matching is not None: otp_counter = check_otp(self, passw, options=options) if otp_counter >= 0: matchin_challenges.append(matching) return (otp_counter, matchin_challenges)
def checkResponse4Challenge(self, user, passw, options=None, challenges=None): """ This method verifies if the given ``passw`` matches any existing ``challenge`` of the token. It then returns the new otp_counter of the token and the list of the matching challenges. In case of success the otp_counter needs to be > 0. The matching_challenges is passed to the method :py:meth:`~linotp.lib.tokenclass.TokenClass.challenge_janitor` to clean up challenges. :param user: the requesting user :type user: User object :param passw: the password (pin+otp) :type passw: string :param options: additional arguments from the request, which could be token specific :type options: dict :param challenges: A sorted list of valid challenges for this token. :type challenges: list :return: tuple of (otpcounter and the list of matching challenges) """ otp_counter = -1 transid = None matching = None matching_challenges = [] # fetch the transactionid if 'transactionid' in options: transid = options.get('transactionid', None) # check if the transactionid is in the list of challenges if transid is not None: for challenge in challenges: if is_same_transaction(challenge, transid): matching = challenge break if matching is not None: # Split pin from otp and check the resulting pin and otpval (res, pin, otpval) = self.splitPinPass(passw) if not check_pin(self, pin, user=user, options=options): otpval = passw # The U2F checkOtp functions needs to know the saved challenge # to compare the received challenge value to the saved one, # thus we add the transactionid to the options options['transactionid'] = transid options['challenges'] = challenges otp_counter = check_otp(self, otpval, options=options) if otp_counter >= 0: matching_challenges.append(matching) return (otp_counter, matching_challenges)
def checkResponse4Challenge(self, user, passw, options=None, challenges=None): ''' verify the response of a previous challenge :param user: the requesting user :param passw: the to be checked pass (pin+otp) :param options: options an additional argument, which could be token specific :param challenges: the list of challenges, where each challenge is described as dict :return: tuple of (otpcounter and the list of matching challenges) ''' otp_counter = -1 transid = None matching = None matchin_challenges = [] if 'transactionid' in options or 'state' in options: ## fetch the transactionid transid = options.get('transactionid', None) if transid is None: transid = options.get('state', None) ## check if the transactionid is in the list of challenges if transid is not None: for challenge in challenges: if challenge.getTransactionId() == transid: matching = challenge break if matching is not None: otp_counter = check_otp(self, passw, options=options) if otp_counter >= 0: matchin_challenges.append(matching) return (otp_counter, matchin_challenges)