views.py 文件源码

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

项目:ssh-ca-server 作者: commercehub-oss 项目源码 文件源码
def requires_auth(function):
    """ Bind against LDAP to validate users credentials """

    @wraps(function)
    def decorated(*args, **kwargs):

        logger = logging.getLogger("ca_server")
        auth = request.authorization
        ldap = LdapClient()

        if not auth or not ldap.check_auth(auth.username, auth.password):
            output = DataBag()
            output.set_error("Access denied")
            if hasattr(auth, "username"):
                logger.info("requires_auth: access denied {}".format(auth.username))
            else:
                logger.info("requires_auth: access denied")
            return output.get_json()

        return function(auth.username)
    return decorated
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号