mirror of
https://gitlab.com/fabinfra/fabaccess/fabfire_adapter.git
synced 2025-03-12 14:51:50 +01:00
25 lines
761 B
Python
25 lines
761 B
Python
import capnp
|
|
capnp.remove_import_hook()
|
|
|
|
connection_capnp = capnp.load('schema/connection.capnp')
|
|
authenticationsystem_capnp = capnp.load('schema/authenticationsystem.capnp')
|
|
|
|
def connect(host, user, pw):
|
|
"""TODO: Docstring for connect.
|
|
:returns: TODO
|
|
|
|
"""
|
|
client = capnp.TwoPartyClient(host)
|
|
boot = client.bootstrap().cast_as(connection_capnp.Bootstrap)
|
|
auth = boot.authenticationSystem().authenticationSystem
|
|
req = auth.start_request()
|
|
req.request.mechanism = "PLAIN"
|
|
req.request.initialResponse.initial = "\0" + user + "\0" + pw
|
|
rep_prom = req.send()
|
|
response = rep_prom.wait()
|
|
if response.response.outcome.result == "successful":
|
|
return boot
|
|
else:
|
|
print("Auth failed")
|
|
return None
|