authentication.py 文件源码

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

项目:munch-core 作者: crunchmail 项目源码 文件源码
def authenticate_credentials(self, username, secret):
        """
        Authenticate the userid and secret against username and secret.

        Tightly bound to .backends.APIKeyMunchUserBackend
        """
        if username != "api":
            raise AuthenticationFailed('Invalid username')

        user = authenticate(secret=secret)
        if user and user.is_active:
            return (user, None)
        api_app = APIApplication.objects.filter(
            secret=secret, author__is_active=True).first()
        if api_app and api_app.author.is_active:
            return (api_app.author, None)

        raise AuthenticationFailed('Invalid API key')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号