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
评论列表
文章目录