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

Commit 450f9c7

Browse files
committed
Merge branch 'master' of github.com:IdentityPython/oidcmsg
2 parents 763eb2a + e2ff696 commit 450f9c7

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/oidcmsg/key_jar.py

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

899899

900-
def init_key_jar(public_path, private_path='', key_defs=''):
900+
def init_key_jar(public_path, private_path='', key_defs='', iss=''):
901901
"""
902902
If a JWKS with private keys exists create a KeyJar from it.
903903
If not, then a set of keys are created based on the keydefs specification.
@@ -911,6 +911,7 @@ def init_key_jar(public_path, private_path='', key_defs=''):
911911
private keys.
912912
:param key_defs: A definition of what keys should be created if they are
913913
not already available
914+
:param iss: Issuer ID
914915
:return: An instantiated :py:class;`oidcmsg.key_jar.KeyJar` instance
915916
"""
916917

@@ -934,9 +935,16 @@ def init_key_jar(public_path, private_path='', key_defs=''):
934935
fp = open(public_path, 'w')
935936
fp.write(json.dumps(jwks))
936937
fp.close()
938+
939+
if iss:
940+
_kj.import_jwks(jwks, iss)
941+
937942
else:
938943
_jwks = open(public_path, 'r').read()
939944
_kj = KeyJar()
940945
_kj.import_jwks(json.loads(_jwks), '')
941946

947+
if iss:
948+
_kj.import_jwks(json.loads(_jwks), iss)
949+
942950
return _kj

src/oidcmsg/oauth2/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
logger = logging.getLogger(__name__)
1616

1717

18+
def is_error_message(msg):
19+
if 'error' in msg:
20+
return True
21+
else:
22+
return False
23+
24+
1825
class ResponseMessage(Message):
1926
"""
2027
The basic error response
@@ -23,12 +30,6 @@ class ResponseMessage(Message):
2330
"error_description": SINGLE_OPTIONAL_STRING,
2431
"error_uri": SINGLE_OPTIONAL_STRING}
2532

26-
def is_error_message(self):
27-
if 'error' in self:
28-
return True
29-
else:
30-
return False
31-
3233

3334
class AuthorizationErrorResponse(ResponseMessage):
3435
"""

tests/test_5_oauth2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from oidcmsg.message import sp_sep_list_deserializer
1515

1616
from oidcmsg.oauth2 import factory
17+
from oidcmsg.oauth2 import is_error_message
1718
from oidcmsg.oauth2 import AccessTokenRequest
1819
from oidcmsg.oauth2 import AccessTokenResponse
1920
from oidcmsg.oauth2 import AuthorizationErrorResponse
@@ -508,12 +509,12 @@ def test_error_message(self):
508509
assert ue_str != ueo_str
509510
assert "error_message" not in ueo_str
510511
assert "error_message" in ue_str
511-
assert err.is_error_message()
512+
assert is_error_message(err)
512513

513514
def test_auth_error_message(self):
514515
resp = AuthorizationResponse(error="invalid_request",
515516
error_description="Something was missing")
516-
assert resp.is_error_message()
517+
assert is_error_message(resp)
517518

518519

519520
def test_factory():

0 commit comments

Comments
 (0)