本文整理汇总了Python中common.crypto.XsrfTokenManager.is_xsrf_token_valid方法的典型用法代码示例。如果您正苦于以下问题:Python XsrfTokenManager.is_xsrf_token_valid方法的具体用法?Python XsrfTokenManager.is_xsrf_token_valid怎么用?Python XsrfTokenManager.is_xsrf_token_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.crypto.XsrfTokenManager
的用法示例。
在下文中一共展示了XsrfTokenManager.is_xsrf_token_valid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert_xsrf_token_or_fail
# 需要导入模块: from common.crypto import XsrfTokenManager [as 别名]
# 或者: from common.crypto.XsrfTokenManager import is_xsrf_token_valid [as 别名]
def assert_xsrf_token_or_fail(self, request, action):
"""Asserts the current request has proper XSRF token or fails."""
token = request.get('xsrf_token')
if not token or not XsrfTokenManager.is_xsrf_token_valid(token, action):
self.error(403)
return False
return True
示例2: assert_xsrf_token_or_fail
# 需要导入模块: from common.crypto import XsrfTokenManager [as 别名]
# 或者: from common.crypto.XsrfTokenManager import is_xsrf_token_valid [as 别名]
def assert_xsrf_token_or_fail(self, token_dict, action, args_dict):
"""Asserts that current request has proper XSRF token or fails."""
token = token_dict.get("xsrf_token")
if not token or not XsrfTokenManager.is_xsrf_token_valid(token, action):
transforms.send_json_response(self, 403, "Bad XSRF token. Please reload the page and try again", args_dict)
return False
return True
示例3: post
# 需要导入模块: from common.crypto import XsrfTokenManager [as 别名]
# 或者: from common.crypto.XsrfTokenManager import is_xsrf_token_valid [as 别名]
def post(self):
"""Handles POST."""
action = self.request.get('action')
if not action or action not in self.post_actions:
self.error(404)
return
handler = getattr(self, 'post_%s' % action)
if not handler:
self.error(404)
return
# Each POST request must have valid XSRF token.
xsrf_token = self.request.get('xsrf_token')
if not XsrfTokenManager.is_xsrf_token_valid(xsrf_token, action):
self.error(403)
return
return handler()