Kitaru

CredentialStore

Server credentials persisted as JSON in the user's config directory.

Attributes

attributepathPath

Return the location of the credentials file.

Functions

func__init__(self, path=None, persist=None) -> None

Initialize the store and load any credentials already on disk.

paramself
parampathPath | None
= None

Location of the credentials file.

parampersistbool | None
= None

Whether to read and write the file. Defaults to reading KITARU_DISABLE_CREDENTIALS_CACHE.

Returns

None
funcget(self, url) -> ServerCredentials | None

Return the credentials stored for a server.

paramself
paramurlstr

Server base URL.

Returns

ServerCredentials | None

Stored credentials, or None when the server is unknown.

funclist(self) -> list[ServerCredentials]

Return the credentials of every known server.

paramself

Returns

list

Stored credentials, ordered by server URL.

funcget_token(self, url, allow_expired=False) -> ApiToken | None

Return the cached token of a server.

paramself
paramurlstr

Server base URL.

paramallow_expiredbool
= False

Whether to return a token inside its leeway window.

Returns

ApiToken | None

Cached token, or None when there is none to return.

funcset_token(self, url, token, type=None, control_plane_api_url=None) -> None

Cache a token for a server.

The control plane is recorded with the token it issued rather than on its own, because an entry that holds neither a token nor a credential is dropped when the store is written.

paramself
paramurlstr

Server base URL.

paramtokenApiToken

Token to cache.

paramtypeApiType | None
= None

API type, left as stored when omitted.

paramcontrol_plane_api_urlstr | None
= None

Control plane that issued the credential behind this token, left as stored when omitted.

Returns

None
funcset_api_key(self, url, api_key, type=ApiType.SERVER) -> None

Store an API key for a server and drop the token it replaces.

paramself
paramurlstr

Server base URL.

paramapi_keystr

API key to store.

paramtypeApiType
= ApiType.SERVER

API type.

Returns

None
funcset_device(self, url, device_id, device_code) -> None

Store a device authorization for a server.

paramself
paramurlstr

Server base URL.

paramdevice_iduuid.UUID

Id of the authorized device.

paramdevice_codestr

Device code the client polls with.

Returns

None
funcget_control_plane(self, control_plane_api_url) -> ServerCredentials | None

Return the credentials stored for a control plane.

paramself
paramcontrol_plane_api_urlstr

Control plane API base URL.

Returns

ServerCredentials | None

Stored credentials, or None when the entry is missing or is not a

funcclear_token(self, url) -> None

Drop the cached token of a server, keeping the way to get a new one.

paramself
paramurlstr

Server base URL.

Returns

None
funcclear(self, url) -> None

Drop every credential stored for a server.

paramself
paramurlstr

Server base URL.

Returns

None
funcclear_all(self) -> None

Drop every stored credential and remove the credentials file.

paramself

Returns

None

On this page