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

Commit 532d464

Browse files
committed
Updated to work with cryptojwt 0.4.4
1 parent ca85670 commit 532d464

File tree

6 files changed

+44
-198
lines changed

6 files changed

+44
-198
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def run_tests(self):
6161
"Programming Language :: Python :: 3.6",
6262
"Topic :: Software Development :: Libraries :: Python Modules"],
6363
install_requires=[
64-
"cryptojwt",
64+
"cryptojwt>=0.4.4",
6565
"pyOpenSSL",
6666
],
6767
zip_safe=False,

src/oidcmsg/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
__author__ = 'Roland Hedberg'
22
__version__ = '0.6.1'
33

4+
45
def proper_path(path):
56
"""
67
Clean up the path specification so it looks like something I could use.

src/oidcmsg/jwt.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/oidcmsg/oidc/__init__.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -714,13 +714,13 @@ def pack(self, alg='', **kwargs):
714714
else:
715715
self.pack_init()
716716

717-
if 'jti' in self.c_param:
718-
try:
719-
_jti = kwargs['jti']
720-
except KeyError:
721-
_jti = uuid.uuid4().hex
722-
723-
self['jti'] = _jti
717+
# if 'jti' in self.c_param:
718+
# try:
719+
# _jti = kwargs['jti']
720+
# except KeyError:
721+
# _jti = uuid.uuid4().hex
722+
#
723+
# self['jti'] = _jti
724724

725725
def to_jwt(self, key=None, algorithm="", lev=0, lifetime=0):
726726
self.pack(alg=algorithm, lifetime=lifetime)
@@ -1197,17 +1197,14 @@ def make_openid_request(arq, keys, issuer, request_object_signing_alg, recv):
11971197
The request will be signed
11981198
11991199
:param arq: The Authorization request
1200-
:param keys: Keys to use for signing/encrypting
1200+
:param keys: Keys to use for signing/encrypting. A KeyJar instance
12011201
:param issuer: Who is signing this JSON Web Token
12021202
:param request_object_signing_alg: Which signing algorithm to use
12031203
:param recv: The intended receiver of the request
12041204
:return: JWT encoded OpenID request
12051205
"""
12061206

1207-
if isinstance(keys, KeyJar):
1208-
keys = keys.get_signing_key()
1209-
1210-
_jwt = JWT(own_keys=keys, iss=issuer, sign_alg=request_object_signing_alg)
1207+
_jwt = JWT(key_jar=keys, iss=issuer, sign_alg=request_object_signing_alg)
12111208
return _jwt.pack(arq.to_dict(), owner=issuer, recv=recv)
12121209

12131210

tests/test_2_jwt.py

Lines changed: 0 additions & 131 deletions
This file was deleted.

tests/test_6_oidc.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
from cryptojwt.key_bundle import KeyBundle
1414
from cryptojwt.key_jar import KeyJar
1515

16-
from oidcmsg import time_util
16+
from oidcmsg import time_util, proper_path
1717
from oidcmsg.exception import MessageException
1818
from oidcmsg.exception import MissingRequiredAttribute
1919
from oidcmsg.exception import NotAllowedValue
2020
from oidcmsg.exception import OidcMsgError
2121
from oidcmsg.exception import WrongSigningAlgorithm
2222
from oidcmsg.oauth2 import ResponseMessage, ROPCAccessTokenRequest
23-
from oidcmsg.oidc import AccessTokenRequest, make_openid_request
23+
from oidcmsg.oidc import AccessTokenRequest, make_openid_request, link_deser
2424
from oidcmsg.oidc import dict_deser
2525
from oidcmsg.oidc import claims_match
2626
from oidcmsg.oidc import link_ser
@@ -1048,3 +1048,34 @@ def test_factory_2():
10481048
inst = factory('ROPCAccessTokenRequest', username='me', password='text',
10491049
scope='mar')
10501050
assert isinstance(inst, ROPCAccessTokenRequest)
1051+
1052+
1053+
def test_link_deser():
1054+
link = Link(href='https://example.com/op',
1055+
rel="http://openid.net/specs/connect/1.0/issuer")
1056+
1057+
jl = link_ser(link, 'json')
1058+
l2 = link_deser([jl], 'json')
1059+
assert isinstance(l2[0], Link)
1060+
1061+
1062+
def test_link_deser_dict():
1063+
link = Link(href='https://example.com/op',
1064+
rel="http://openid.net/specs/connect/1.0/issuer")
1065+
1066+
l2 = link_deser([link.to_dict()], 'json')
1067+
assert isinstance(l2[0], Link)
1068+
1069+
1070+
def test_proper_path():
1071+
p = proper_path('foo/bar')
1072+
assert p == './foo/bar/'
1073+
1074+
p = proper_path('/foo/bar')
1075+
assert p == './foo/bar/'
1076+
1077+
p = proper_path('./foo/bar')
1078+
assert p == './foo/bar/'
1079+
1080+
p = proper_path('../foo/bar')
1081+
assert p == './foo/bar/'

0 commit comments

Comments
 (0)