1111from .key_issuer import KeyIssuer
1212from .key_issuer import build_keyissuer
1313from .key_issuer import init_key_issuer
14+ from .utils import deprecated_alias
1415from .utils import importer
1516from .utils import qualified_name
1617
@@ -79,6 +80,7 @@ def _issuer_ids(self) -> List[str]:
7980 """
8081 return list (self ._issuers .keys ())
8182
83+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
8284 def _get_issuer (self , issuer_id : str ) -> Optional [KeyIssuer ]:
8385 """
8486 Return the KeyIssuer instance that has name == issuer_id
@@ -89,6 +91,7 @@ def _get_issuer(self, issuer_id: str) -> Optional[KeyIssuer]:
8991
9092 return self ._issuers .get (issuer_id )
9193
94+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
9295 def _add_issuer (self , issuer_id ) -> KeyIssuer :
9396 _iss = KeyIssuer (ca_certs = self .ca_certs , name = issuer_id ,
9497 keybundle_cls = self .keybundle_cls ,
@@ -109,6 +112,7 @@ def __repr__(self):
109112 issuers = self ._issuer_ids ()
110113 return '<KeyJar(issuers={})>' .format (issuers )
111114
115+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
112116 def return_issuer (self , issuer_id ):
113117 """
114118 Return a KeyIssuer instance with name == issuer_id.
@@ -122,6 +126,7 @@ def return_issuer(self, issuer_id):
122126 return self ._add_issuer (issuer_id )
123127 return _iss
124128
129+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
125130 def add_url (self , issuer_id : str , url : str , ** kwargs ) -> KeyBundle :
126131 """
127132 Add a set of keys by url. This method will create a
@@ -139,20 +144,22 @@ def add_url(self, issuer_id: str, url: str, **kwargs) -> KeyBundle:
139144 kb = issuer .add_url (url , ** kwargs )
140145 return kb
141146
147+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
142148 def add_symmetric (self , issuer_id , key , usage = None ):
143149 """
144150 Add a symmetric key. This is done by wrapping it in a key bundle
145151 cloak since KeyJar does not handle keys directly but only through
146152 key bundles.
147153
148- :param issuer : Owner of the key
154+ :param issuer_id : Owner of the key
149155 :param key: The key
150156 :param usage: What the key can be used for signing/signature
151157 verification (sig) and/or encryption/decryption (enc)
152158 """
153159 issuer = self .return_issuer (issuer_id )
154160 issuer .add_symmetric (key , usage = usage )
155161
162+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
156163 def add_kb (self , issuer_id , kb ):
157164 """
158165 Add a key bundle and bind it to an identifier
@@ -164,6 +171,7 @@ def add_kb(self, issuer_id, kb):
164171 issuer .add_kb (kb )
165172 self [issuer_id ] = issuer
166173
174+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
167175 def get (self , key_use , key_type = "" , issuer_id = "" , kid = None , ** kwargs ):
168176 """
169177 Get all keys that matches a set of search criteria
@@ -242,6 +250,7 @@ def get(self, key_use, key_type="", issuer_id="", kid=None, **kwargs):
242250 #
243251 # return lst
244252
253+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
245254 def get_signing_key (self , key_type = "" , issuer_id = "" , kid = None , ** kwargs ):
246255 """
247256 Shortcut to use for signing keys only.
@@ -254,15 +263,19 @@ def get_signing_key(self, key_type="", issuer_id="", kid=None, **kwargs):
254263 """
255264 return self .get ("sig" , key_type , issuer_id , kid , ** kwargs )
256265
266+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
257267 def get_verify_key (self , key_type = "" , issuer_id = "" , kid = None , ** kwargs ):
258268 return self .get ("ver" , key_type , issuer_id , kid , ** kwargs )
259269
270+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
260271 def get_encrypt_key (self , key_type = "" , issuer_id = "" , kid = None , ** kwargs ):
261272 return self .get ("enc" , key_type , issuer_id , kid , ** kwargs )
262273
274+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
263275 def get_decrypt_key (self , key_type = "" , issuer_id = "" , kid = None , ** kwargs ):
264276 return self .get ("dec" , key_type , issuer_id , kid , ** kwargs )
265277
278+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
266279 def keys_by_alg_and_usage (self , issuer_id , alg , usage ):
267280 """
268281 Find all keys that can be used for a specific crypto algorithm and
@@ -280,11 +293,12 @@ def keys_by_alg_and_usage(self, issuer_id, alg, usage):
280293
281294 return self .get (usage , ktype , issuer_id )
282295
296+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
283297 def get_issuer_keys (self , issuer_id ):
284298 """
285299 Get all the keys that belong to an entity.
286300
287- :param issuer : The entity ID
301+ :param issuer_id : The entity ID
288302 :return: A possibly empty list of keys
289303 """
290304 _issuer = self ._get_issuer (issuer_id )
@@ -293,12 +307,14 @@ def get_issuer_keys(self, issuer_id):
293307 else :
294308 return []
295309
310+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
296311 def __contains__ (self , issuer_id ):
297312 if self ._get_issuer (issuer_id ):
298313 return True
299314 else :
300315 return False
301316
317+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
302318 def __getitem__ (self , issuer_id = '' ):
303319 """
304320 Get all the KeyIssuer with the name == issuer_id
@@ -308,14 +324,15 @@ def __getitem__(self, issuer_id=''):
308324 """
309325 return self ._get_issuer (issuer_id )
310326
311- def __setitem__ (self , issuer_id , issuer ):
327+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
328+ def __setitem__ (self , issuer_id , key_issuer ):
312329 """
313330 Set a KeyIssuer with the name == issuer_id
314331
315332 :param issuer_id: The entity ID
316- :param issuer : KeyIssuer instance
333+ :param key_issuer : KeyIssuer instance
317334 """
318- self ._issuers [issuer_id ] = issuer
335+ self ._issuers [issuer_id ] = key_issuer
319336
320337 def set (self , issuer_id , issuer ):
321338 self [issuer_id ] = issuer
@@ -349,13 +366,14 @@ def __str__(self):
349366 _res [_id ] = _issuer .key_summary ()
350367 return json .dumps (_res )
351368
369+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
352370 def load_keys (self , issuer_id , jwks_uri = '' , jwks = None , replace = False ):
353371 """
354372 Fetch keys from another server
355373
356374 :param jwks_uri: A URL pointing to a site that will return a JWKS
357375 :param jwks: A dictionary representation of a JWKS
358- :param issuer : The provider URL
376+ :param issuer_id : The provider URL
359377 :param replace: If all previously gathered keys from this provider
360378 should be replace.
361379 :return: Dictionary with usage as key and keys as values
@@ -376,12 +394,13 @@ def load_keys(self, issuer_id, jwks_uri='', jwks=None, replace=False):
376394
377395 self [issuer_id ] = _issuer
378396
397+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
379398 def find (self , source , issuer_id = None ):
380399 """
381400 Find a key bundle based on the source of the keys
382401
383402 :param source: A source url
384- :param issuer : The issuer of keys
403+ :param issuer_id : The issuer of keys
385404 :return: List of :py:class:`oidcmsg.key_bundle.KeyBundle` instances or None
386405 """
387406 if issuer_id is None :
@@ -399,13 +418,14 @@ def find(self, source, issuer_id=None):
399418
400419 return res
401420
421+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
402422 def export_jwks (self , private = False , issuer_id = "" , usage = None ):
403423 """
404424 Produces a dictionary that later can be easily mapped into a
405425 JSON string representing a JWKS.
406426
407427 :param private: Whether it should be the private keys or the public
408- :param issuer : The entity ID.
428+ :param issuer_id : The entity ID.
409429 :return: A dictionary with one key: 'keys'
410430 """
411431 _issuer = self ._get_issuer (issuer_id = issuer_id )
@@ -419,6 +439,7 @@ def export_jwks(self, private=False, issuer_id="", usage=None):
419439 usage is None or (hasattr (k , 'use' ) and k .use == usage ))])
420440 return {"keys" : keys }
421441
442+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
422443 def export_jwks_as_json (self , private = False , issuer_id = "" ):
423444 """
424445 Export a JWKS as a JSON document.
@@ -429,6 +450,7 @@ def export_jwks_as_json(self, private=False, issuer_id=""):
429450 """
430451 return json .dumps (self .export_jwks (private , issuer_id ))
431452
453+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
432454 def import_jwks (self , jwks , issuer_id ):
433455 """
434456 Imports all the keys that are represented in a JWKS
@@ -447,16 +469,18 @@ def import_jwks(self, jwks, issuer_id):
447469 httpc_params = self .httpc_params ))
448470 self [issuer_id ] = _issuer
449471
472+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
450473 def import_jwks_as_json (self , jwks , issuer_id ):
451474 """
452475 Imports all the keys that are represented in a JWKS expressed as a
453476 JSON object
454477
455478 :param jwks: JSON representation of a JWKS
456- :param issuer : Who 'owns' the JWKS
479+ :param issuer_id : Who 'owns' the JWKS
457480 """
458481 return self .import_jwks (json .loads (jwks ), issuer_id )
459482
483+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
460484 def import_jwks_from_file (self , filename , issuer_id ):
461485 with open (filename ) as jwks_file :
462486 self .import_jwks_as_json (jwks_file .read (), issuer_id )
@@ -495,6 +519,7 @@ def remove_outdated(self, when=0):
495519 _before = len (_issuer )
496520 _issuer .remove_outdated (when )
497521
522+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
498523 def _add_key (self , keys , issuer_id , use , key_type = '' , kid = '' ,
499524 no_kid_issuer = None , allow_missing_kid = False ):
500525
@@ -695,6 +720,7 @@ def load(self, info):
695720 self ._issuers [_issuer_id ] = KeyIssuer ().load (_issuer_desc )
696721 return self
697722
723+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
698724 def key_summary (self , issuer_id ):
699725 _issuer = self ._get_issuer (issuer_id )
700726 if _issuer :
@@ -706,15 +732,20 @@ def update(self):
706732 """
707733 Go through the whole key jar, key issuer by key issuer and update them one
708734 by one.
709-
710- :param keyjar: The key jar to update
711735 """
712736 ids = self ._issuers .keys ()
713737 for _id in ids :
714738 _issuer = self [_id ]
715739 _issuer .update ()
716740 self [_id ] = _issuer
717741
742+ @deprecated_alias (issuer = 'issuer_id' , owner = 'issuer_id' )
743+ def rotate_keys (self , key_conf , kid_template = "" , issuer_id = '' ):
744+ _issuer = self [issuer_id ]
745+ _issuer .rotate_keys (key_conf = key_conf , kid_template = kid_template )
746+ self [issuer_id ] = _issuer
747+ return self
748+
718749
719750# =============================================================================
720751
@@ -807,21 +838,16 @@ def init_key_jar(public_path='', private_path='', key_defs='', issuer_id='', rea
807838
808839 The keys stored in the KeyJar will be stored under the '' identifier.
809840
810- :param public_path: A file path to a file that contains a JWKS with public
811- keys
812- :param private_path: A file path to a file that contains a JWKS with
813- private keys.
814- :param key_defs: A definition of what keys should be created if they are
815- not already available
841+ :param public_path: A file path to a file that contains a JWKS with public keys
842+ :param private_path: A file path to a file that contains a JWKS with private keys.
843+ :param key_defs: A definition of what keys should be created if they are not already available
816844 :param issuer_id: The owner of the keys
817- :param read_only: This function should not attempt to write anything
818- to a file system.
845+ :param read_only: This function should not attempt to write anything to a file system.
819846 :return: An instantiated :py:class;`oidcmsg.key_jar.KeyJar` instance
820847 """
821848
822849 _issuer = init_key_issuer (public_path = public_path , private_path = private_path ,
823- key_defs = key_defs , read_only = read_only ,
824- storage_conf = storage_conf , abstract_storage_cls = abstract_storage_cls )
850+ key_defs = key_defs , read_only = read_only )
825851
826852 if _issuer is None :
827853 raise ValueError ('Could not find any keys' )
0 commit comments