Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 38b3918

Browse files
committed
Allow the imported keys to be stores under '' == the entity itself and under the entity ID. The later only if iss is specified. Useful when an entity is signing something later to be verified by itself.
1 parent 42f69d8 commit 38b3918

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/oidcmsg/key_jar.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ def public_keys_keyjar(from_kj, origin, to_kj=None, receiver=''):
909909
return to_kj
910910

911911

912-
def init_key_jar(public_path, private_path='', key_defs=''):
912+
def init_key_jar(public_path, private_path='', key_defs='', iss=''):
913913
"""
914914
If a JWKS with private keys exists create a KeyJar from it.
915915
If not, then a set of keys are created based on the keydefs specification.
@@ -923,6 +923,7 @@ def init_key_jar(public_path, private_path='', key_defs=''):
923923
private keys.
924924
:param key_defs: A definition of what keys should be created if they are
925925
not already available
926+
:param iss: Issuer ID
926927
:return: An instantiated :py:class;`oidcmsg.key_jar.KeyJar` instance
927928
"""
928929

@@ -946,9 +947,16 @@ def init_key_jar(public_path, private_path='', key_defs=''):
946947
fp = open(public_path, 'w')
947948
fp.write(json.dumps(jwks))
948949
fp.close()
950+
951+
if iss:
952+
_kj.import_jwks(jwks, iss)
953+
949954
else:
950955
_jwks = open(public_path, 'r').read()
951956
_kj = KeyJar()
952957
_kj.import_jwks(json.loads(_jwks), '')
953958

959+
if iss:
960+
_kj.import_jwks(json.loads(_jwks), iss)
961+
954962
return _kj

0 commit comments

Comments
 (0)