22
22
23
23
24
24
class KeyIssuer (object ):
25
- """ A issuer contains a number of KeyBundles. """
25
+ """ A key issuer instance contains a number of KeyBundles. """
26
26
27
27
def __init__ (self , ca_certs = None , keybundle_cls = KeyBundle ,
28
28
remove_after = 3600 , httpc = None , httpc_params = None ,
@@ -69,7 +69,6 @@ def add_url(self, url, **kwargs):
69
69
url as source specification. If no file format is given it's assumed
70
70
that what's on the other side is a JWKS.
71
71
72
- :param issuer: Who issued the keys
73
72
:param url: Where can the key/-s be found
74
73
:param kwargs: extra parameters for instantiating KeyBundle
75
74
:return: A :py:class:`oidcmsg.oauth2.keybundle.KeyBundle` instance
@@ -234,19 +233,19 @@ def import_jwks(self, jwks):
234
233
self ._bundles .append (
235
234
self .keybundle_cls (_keys , httpc = self .httpc , httpc_params = self .httpc_params ))
236
235
237
- def import_jwks_as_json (self , jwks , issuer ):
236
+ def import_jwks_as_json (self , jwks , issuer_id ):
238
237
"""
239
238
Imports all the keys that are represented in a JWKS expressed as a
240
239
JSON object
241
240
242
241
:param jwks: JSON representation of a JWKS
243
- :param issuer : Who 'owns' the JWKS
242
+ :param issuer_id : Who 'owns' the JWKS
244
243
"""
245
244
return self .import_jwks (json .loads (jwks ))
246
245
247
- def import_jwks_from_file (self , filename , issuer ):
246
+ def import_jwks_from_file (self , filename , issuer_id ):
248
247
with open (filename ) as jwks_file :
249
- self .import_jwks_as_json (jwks_file .read (), issuer )
248
+ self .import_jwks_as_json (jwks_file .read (), issuer_id )
250
249
251
250
def remove_outdated (self , when = 0 ):
252
251
"""
@@ -352,7 +351,7 @@ def __len__(self):
352
351
353
352
def dump (self , exclude = None ):
354
353
"""
355
- Returns the key issuer content as a dictionary.
354
+ Returns the content as a dictionary.
356
355
357
356
:return: A dictionary
358
357
"""
@@ -447,6 +446,20 @@ def __eq__(self, other):
447
446
448
447
return True
449
448
449
+ def rotate_keys (self , key_conf , kid_template = "" ):
450
+ """
451
+
452
+ :param key_conf: The configuration for the new keys
453
+ :param issuer: KeyIssuer instance
454
+ :param kid_template: A key id template
455
+ :return:
456
+ """
457
+ new_keys = build_keyissuer (key_conf , kid_template )
458
+ self .mark_all_keys_as_inactive ()
459
+ for kb in new_keys :
460
+ self .add_kb (kb )
461
+ return self
462
+
450
463
451
464
# =============================================================================
452
465
@@ -489,6 +502,7 @@ def build_keyissuer(key_conf, kid_template="", key_issuer=None, issuer_id=''):
489
502
:param kid_template: A template by which to build the key IDs. If no
490
503
kid_template is given then the built-in function add_kid() will be used.
491
504
:param key_issuer: If an keyIssuer instance the new keys are added to this key issuer.
505
+ :param issuer_id: The identifier of the issuer
492
506
:return: A KeyIssuer instance
493
507
"""
494
508
@@ -504,16 +518,7 @@ def build_keyissuer(key_conf, kid_template="", key_issuer=None, issuer_id=''):
504
518
return key_issuer
505
519
506
520
507
- def rotate_keys (key_conf , issuer , kid_template = "" ):
508
- new_keys = build_keyissuer (key_conf , kid_template )
509
- issuer .mark_all_keys_as_inactive ()
510
- for kb in new_keys :
511
- issuer .add_kb (kb )
512
- return issuer
513
-
514
-
515
- def init_key_issuer (public_path = '' , private_path = '' , key_defs = '' , read_only = True ,
516
- storage_conf = None , abstract_storage_cls = None ):
521
+ def init_key_issuer (public_path = '' , private_path = '' , key_defs = '' , read_only = True ):
517
522
"""
518
523
A number of cases here:
519
524
0 commit comments