internalapi.py 文件源码

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

项目:CommunityCellularManager 作者: facebookincubator 项目源码 文件源码
def authenticate(self, request):
        """Implements a custom authentication scheme using a BTS uuid in the
        request and cross references it with a whitelist.

        Returns: (user, auth) if authentication succeeds or None if this scheme
                 is not attempted, and another authentication scheme should be
                 attempted

        Raises: AuthenticationFailed exception if an invalid or a
                non-whitelisted BTS uuid is provided
        """
        if "number" not in request.GET:
            # Not attempting whitelist auth scheme.
            return None
        try:
            query_number = request.GET["number"]
            number = Number.objects.get(number=query_number)
            if number.network.bypass_gateway_auth:
                return (number.network.auth_user, None)
            else:
                raise AuthenticationFailed("Number authentication failed.")
        except Number.DoesNotExist:
            raise AuthenticationFailed("Unknown number.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号