本文整理匯總了Python中linotp.lib.challenges.Challenges.handle_related_challenge方法的典型用法代碼示例。如果您正苦於以下問題:Python Challenges.handle_related_challenge方法的具體用法?Python Challenges.handle_related_challenge怎麽用?Python Challenges.handle_related_challenge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類linotp.lib.challenges.Challenges
的用法示例。
在下文中一共展示了Challenges.handle_related_challenge方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: checkTokenList
# 需要導入模塊: from linotp.lib.challenges import Challenges [as 別名]
# 或者: from linotp.lib.challenges.Challenges import handle_related_challenge [as 別名]
#.........這裏部分代碼省略.........
log.debug('Found user with loginId %r: %r:\n',
token.getUserId(), token.getSerial())
audit_entry['serial'] = token.getSerial()
audit_entry['token_type'] = token.getType()
# preselect: the token must be in the same realm as the user
if user is not None:
t_realms = token.token.getRealmNames()
u_realm = user.getRealm()
if (len(t_realms) > 0 and len(u_realm) > 0 and
u_realm.lower() not in t_realms):
audit_entry['action_detail'] = ("Realm mismatch for "
"token and user")
continue
# check if the token is the list of supported tokens
# if not skip to the next token in list
typ = token.getType()
if typ.lower() not in tokenclasses:
log.error('token typ %r not found in tokenclasses: %r' %
(typ, tokenclasses))
audit_entry['action_detail'] = "Unknown Token type"
continue
if not token.isActive():
audit_entry['action_detail'] = "Token inactive"
continue
if token.getFailCount() >= token.getMaxFailCount():
audit_entry['action_detail'] = "Failcounter exceeded"
continue
if not token.check_auth_counter():
audit_entry['action_detail'] = "Authentication counter exceeded"
continue
if not token.check_validity_period():
audit_entry['action_detail'] = "validity period mismatch"
continue
# start the token validation
try:
# are there outstanding challenges
(_ex_challenges,
challenges) = Challenges.get_challenges(token,
options=check_options)
(ret, reply) = token.check_token(
passw, user, options=check_options, challenges=challenges)
except Exception as exx:
# in case of a failure during checking token, we log the error
# and continue with the next one
log.exception("checking token %r failed: %r" % (token, exx))
ret = -1
reply = "%r" % exx
audit_entry['action_detail'] = ("checking token %r "
"failed: %r" % (token, exx))
continue
finally:
validation_results[token.getSerial()] = (ret, reply)
(cToken, pToken, iToken, vToken) = token.get_verification_result()
related_challenges.extend(token.related_challenges)
challenge_tokens.extend(cToken)
pin_matching_tokens.extend(pToken)
invalid_tokens.extend(iToken)
valid_tokens.extend(vToken)
# end of token verification loop
# if there are related / sub challenges, we have to call their janitor
Challenges.handle_related_challenge(related_challenges)
# now we finalize the token validation result
fh = FinishTokens(valid_tokens,
challenge_tokens,
pin_matching_tokens,
invalid_tokens,
validation_results,
user, options,
audit_entry=audit_entry)
(res, reply) = fh.finish_checked_tokens()
# add to all tokens the last accessd time stamp
linotp.lib.token.add_last_accessed_info(
[valid_tokens, pin_matching_tokens, challenge_tokens, valid_tokens])
# now we care for all involved tokens and their challenges
for token in (valid_tokens + pin_matching_tokens +
challenge_tokens + valid_tokens):
expired, _valid = Challenges.get_challenges(token)
if expired:
Challenges.delete_challenges(None, expired)
log.debug("Number of valid tokens found "
"(validTokenNum): %d" % len(valid_tokens))
return (res, reply)
示例2: checkTokenList
# 需要導入模塊: from linotp.lib.challenges import Challenges [as 別名]
# 或者: from linotp.lib.challenges.Challenges import handle_related_challenge [as 別名]
#.........這裏部分代碼省略.........
if token_access_exceed:
msg = "Authentication counter exceeded"
if token_success_excceed:
msg = "Authentication sucess counter exceeded"
if token_expiry:
msg = "Authentication validity period exceeded!"
audit_entry['action_detail'] = msg
token.incOtpFailCounter()
# what should happen with exceeding tokens
t_realms = None
if not user.login and not user.realm:
t_realms = token.token.getRealmNames()
if disable_on_authentication_exceed(user, realms=t_realms):
token.enable(False)
if delete_on_authentication_exceed(user, realms=t_realms):
token.deleteToken()
continue
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# start the token validation
if not transid:
# if there is no transaction id given we check all token
# related challenges
(_ex_challenges,
challenges) = Challenges.get_challenges(token,
options=check_options,
filter_open=True)
try:
(ret, reply) = token.check_token(
passw, user, options=check_options, challenges=challenges)
except Exception as exx:
# in case of a failure during checking token, we log the error
# and continue with the next one
log.exception("checking token %r failed: %r" % (token, exx))
ret = -1
reply = "%r" % exx
audit_entry['action_detail'] = ("checking token %r "
"failed: %r" % (token, exx))
audit_entry['info'] = audit_entry.get('info','') + "%r" % exx
continue
finally:
validation_results[token.getSerial()] = (ret, reply)
(cToken, pToken, iToken, vToken) = token.get_verification_result()
related_challenges.extend(token.related_challenges)
challenge_tokens.extend(cToken)
pin_matching_tokens.extend(pToken)
invalid_tokens.extend(iToken)
valid_tokens.extend(vToken)
# end of token verification loop
matching_challenges = []
for token in valid_tokens:
matching_challenges.extend(token.matching_challenges)
# if there are related / sub challenges, we have to call their janitor
Challenges.handle_related_challenge(matching_challenges)
# now we finalize the token validation result
fh = FinishTokens(valid_tokens,
challenge_tokens,
pin_matching_tokens,
invalid_tokens,
validation_results,
user, options,
audit_entry=audit_entry)
(res, reply) = fh.finish_checked_tokens()
# add to all tokens the last accessd time stamp
add_last_accessed_info(
[valid_tokens, pin_matching_tokens, challenge_tokens, valid_tokens])
# now we care for all involved tokens and their challenges
for token in (valid_tokens + pin_matching_tokens +
challenge_tokens + invalid_tokens):
expired, _valid = Challenges.get_challenges(token)
if expired:
Challenges.delete_challenges(None, expired)
log.debug("Number of valid tokens found "
"(validTokenNum): %d" % len(valid_tokens))
return (res, reply)