Skip to content

Commit

Permalink
pylxd/client: fix auth without password support
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Deziel <[email protected]>
  • Loading branch information
simondeziel committed Sep 10, 2024
1 parent a1ac877 commit d131c01
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pylxd/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,15 @@ def assert_has_api_extension(self, name):
if not self.has_api_extension(name):
raise exceptions.LXDAPIExtensionNotAvailable(name)

def authenticate(self, secret):
def authenticate(self, secret, use_token_auth=True):
if self.trusted:
return
cert = open(self.api.session.cert[0]).read().encode("utf-8")
self.certificates.create(secret, cert)

if self.has_api_extension("explicit_trust_token") and use_token_auth:
self.certificates.create(password="", cert_data=cert, secret=secret)
else:
self.certificates.create(password=secret, cert_data=cert)

# Refresh the host info
response = self.api.get()
Expand Down

0 comments on commit d131c01

Please sign in to comment.