KeyCache

class scitokens.utils.keycache.KeyCache[source]

Bases: object

Object that persistently caches signing keys associated with a token issuer endpoint.

Methods Summary

add_key(issuer, key_id[, force_refresh])

Add a key or update an existing one in keycache

addkeyinfo(issuer, key_id, public_key[, ...])

Add a single, known public key to the cache.

getinstance()

Return the singleton instance of the KeyCache.

getkeyinfo(issuer[, key_id, insecure, ...])

Get the key information

list_keys()

List all keys in keycache

remove_key(issuer, key_id)

Remove a specific key from keycache

update_all_keys([force_refresh])

Update all keys in keycache If force_refresh is True, we refresh all keys regardless of update time

Methods Documentation

add_key(issuer, key_id, force_refresh=False)[source]

Add a key or update an existing one in keycache

addkeyinfo(issuer, key_id, public_key, cache_timer=0, next_update=0)[source]

Add a single, known public key to the cache.

Parameters:
  • issuer (str) – URI of the issuer

  • key_id (str) – Key Identifier

  • public_key – Cryptography public_key object

  • cache_timer (int) – Cache lifetime of the public_key

  • next_update (int) – Seconds until next update time

static getinstance()[source]

Return the singleton instance of the KeyCache.

getkeyinfo(issuer, key_id=None, insecure=False, force_refresh=False, cache_retry_interval=300)[source]

Get the key information

Parameters:
  • issuer (str) – The issuer URI

  • key_id (str) – Text key id to identify the key

  • insecure (bool) – Whether insecure methods are acceptable (defaults to False).

Returns:

None if no key is found. Else, returns the public key

list_keys()[source]

List all keys in keycache

remove_key(issuer, key_id)[source]

Remove a specific key from keycache

update_all_keys(force_refresh=False)[source]

Update all keys in keycache If force_refresh is True, we refresh all keys regardless of update time