proxy.py 文件源码

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

项目:privacyidea-ldap-proxy 作者: NetKnights-GmbH 项目源码 文件源码
def request_validate(self, url, user, realm, password):
        """
        Issue an HTTP request to authenticate an user with a password in a given
        realm using the specified privacyIDEA /validate/check endpoint.

        :param url: an HTTP or HTTPS url to the /validate/check endpoint
        :param user: username to authenticate
        :param realm: realm of the user, empty string for default realm
        :param password: password for authentication
        :return: A Twisted Deferred which yields a `twisted.web.client.Response` instance or fails.
        """
        body = urllib.urlencode({'user': user,
                                'realm': realm,
                                'pass': password})
        # TODO: Is this really the preferred way to pass a string body?
        producer = FileBodyProducer(StringIO(body))
        d = self.factory.agent.request('POST',
                           url,
                           Headers({
                               'Content-Type': ['application/x-www-form-urlencoded'],
                               'User-Agent': ['privacyIDEA-LDAP-Proxy']
                           }),
                           producer)
        return d
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号