coreapi.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Sentry 作者: NetEaseGame 项目源码 文件源码
def project_from_auth(self, auth):
        if not 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 Project.objects.get_from_cache(id=pk.project_id)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号