本文整理汇总了Python中sentry.models.ProjectKey.looks_like_api_key方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectKey.looks_like_api_key方法的具体用法?Python ProjectKey.looks_like_api_key怎么用?Python ProjectKey.looks_like_api_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentry.models.ProjectKey
的用法示例。
在下文中一共展示了ProjectKey.looks_like_api_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: project_key_from_auth
# 需要导入模块: from sentry.models import ProjectKey [as 别名]
# 或者: from sentry.models.ProjectKey import looks_like_api_key [as 别名]
def project_key_from_auth(self, auth):
if not auth.public_key:
raise APIUnauthorized('Invalid api key')
# Make sure the key even looks valid first, since it's
# possible to get some garbage input here causing further
# issues trying to query it from cache or the database.
if not ProjectKey.looks_like_api_key(auth.public_key):
raise APIUnauthorized('Invalid api key')
try:
pk = ProjectKey.objects.get_from_cache(public_key=auth.public_key)
except ProjectKey.DoesNotExist:
raise APIUnauthorized('Invalid api key')
# a secret key may not be present which will be validated elsewhere
if not constant_time_compare(pk.secret_key, auth.secret_key or pk.secret_key):
raise APIUnauthorized('Invalid api key')
if not pk.is_active:
raise APIUnauthorized('API key is disabled')
if not pk.roles.store:
raise APIUnauthorized('Key does not allow event storage access')
return pk