mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-27 17:36:23 +02:00
Add JWT login support
This commit is contained in:
parent
0ca0f9999c
commit
7be781b6e2
2 changed files with 210 additions and 1 deletions
|
|
@ -112,6 +112,29 @@ class IamClient(RequestResponse):
|
|||
timeout=timeout,
|
||||
)
|
||||
|
||||
async def login(self, username, password, workspace="",
|
||||
timeout=IAM_TIMEOUT):
|
||||
"""Validate credentials and return ``(jwt, expires_iso)``.
|
||||
``workspace`` is optional; defaults at the server to the
|
||||
OSS default workspace."""
|
||||
resp = await self._request(
|
||||
operation="login",
|
||||
workspace=workspace,
|
||||
username=username,
|
||||
password=password,
|
||||
timeout=timeout,
|
||||
)
|
||||
return resp.jwt, resp.jwt_expires
|
||||
|
||||
async def get_signing_key_public(self, timeout=IAM_TIMEOUT):
|
||||
"""Return the active JWT signing public key in PEM. The
|
||||
gateway calls this at startup and caches the result."""
|
||||
resp = await self._request(
|
||||
operation="get-signing-key-public",
|
||||
timeout=timeout,
|
||||
)
|
||||
return resp.signing_key_public
|
||||
|
||||
|
||||
class IamClientSpec(RequestResponseSpec):
|
||||
def __init__(self, request_name, response_name):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue