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

Commit 3b7d667

Browse files
authored
Merge pull request #18 from IdentityPython/develop
Develop
2 parents d32baa6 + 7fcd35b commit 3b7d667

File tree

11 files changed

+64
-15
lines changed

11 files changed

+64
-15
lines changed

.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# .coveragerc to control coverage.py
2+
[run]
3+
source = .

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ addons:
1111
-
1212
install:
1313
- pip install codecov
14+
- pip install isort
1415
- pip install tox
1516
- pip install tox-travis
1617
script:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ If some of these keys have a common origin, like described in a JWKS.
2323
Such a set will be kept in a **keyBundle**.
2424
Also implemented in this package.
2525

26+
Please read the [Official Documentation](https://oidcmsg.readthedocs.io/) for getting usage examples and further informations.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def run_tests(self):
5656
classifiers=[
5757
"Development Status :: 4 - Beta",
5858
"License :: OSI Approved :: Apache Software License",
59-
"Programming Language :: Python :: 3.5",
6059
"Programming Language :: Python :: 3.6",
6160
"Programming Language :: Python :: 3.7",
61+
"Programming Language :: Python :: 3.8",
6262
"Topic :: Software Development :: Libraries :: Python Modules"],
6363
install_requires=[
6464
"cryptojwt>=1.1.0",

src/oidcmsg/__init__.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'Roland Hedberg'
2-
__version__ = '1.1.0'
2+
__version__ = '1.1.2'
33

44
VERIFIED_CLAIM_PREFIX = '__verified'
55

@@ -29,3 +29,33 @@ def proper_path(path):
2929
path += "/"
3030

3131
return path
32+
33+
34+
# This is for adding a base path to path specified in a configuration
35+
def add_base_path(conf, item_paths, base_path):
36+
for section, items in item_paths.items():
37+
if section == "":
38+
part = conf
39+
else:
40+
part = conf.get(section)
41+
42+
if part:
43+
if isinstance(items, list):
44+
for attr in items:
45+
_path = part.get(attr)
46+
if _path:
47+
if _path.startswith("/"):
48+
continue
49+
elif _path == "":
50+
part[attr] = "./" + _path
51+
else:
52+
part[attr] = os.path.join(base_path, _path)
53+
elif items is None:
54+
if part.startswith("/"):
55+
continue
56+
elif part == "":
57+
conf[section] = "./"
58+
else:
59+
conf[section] = os.path.join(base_path, part)
60+
else: # Assume items is dictionary like
61+
add_base_path(part, items, base_path)

src/oidcmsg/context.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def add_issuer(conf, issuer):
1616
if key == 'abstract_storage_cls':
1717
res[key] = val
1818
else:
19-
_val = copy.deepcopy(val)
19+
_val = copy.copy(val)
2020
_val['issuer'] = quote_plus(issuer)
2121
res[key] = _val
2222
return res
@@ -36,7 +36,7 @@ def __init__(self, config=None, keyjar=None, entity_id=''):
3636
if self.db_conf.get('default'):
3737
self.db = init_storage(self.db_conf)
3838
else:
39-
self.db = None
39+
self.db = init_storage()
4040
else:
4141
self.db = init_storage()
4242

@@ -48,10 +48,11 @@ def add_boxes(self, boxes, db_conf):
4848

4949
def _keyjar(self, keyjar=None, db_conf=None, conf=None, entity_id=''):
5050
if keyjar is None:
51+
_storage = None
5152
if db_conf:
52-
_storage = storage_factory(get_storage_conf(db_conf, 'keyjar'))
53-
else:
54-
_storage = None
53+
_cnf = get_storage_conf(db_conf, 'keyjar')
54+
if _cnf:
55+
_storage = storage_factory(_cnf)
5556

5657
if 'keys' in conf:
5758
args = {k: v for k, v in conf["keys"].items() if k != "uri_path"}

src/oidcmsg/oidc/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,8 @@ def factory(msgtype, **kwargs):
11571157
return oauth2.factory(msgtype, **kwargs)
11581158

11591159

1160-
def make_openid_request(arq, keys, issuer, request_object_signing_alg, recv):
1160+
def make_openid_request(arq, keys, issuer, request_object_signing_alg, recv, with_jti=False,
1161+
lifetime=0):
11611162
"""
11621163
Construct the JWT to be passed by value (the request parameter) or by
11631164
reference (request_uri).
@@ -1168,10 +1169,16 @@ def make_openid_request(arq, keys, issuer, request_object_signing_alg, recv):
11681169
:param issuer: Who is signing this JSON Web Token
11691170
:param request_object_signing_alg: Which signing algorithm to use
11701171
:param recv: The intended receiver of the request
1172+
:param with_jti: Whether a JTI should be included in the JWT.
1173+
:param lifetime: How long the JWT is expect to be live.
11711174
:return: JWT encoded OpenID request
11721175
"""
11731176

11741177
_jwt = JWT(key_jar=keys, iss=issuer, sign_alg=request_object_signing_alg)
1178+
if with_jti:
1179+
_jwt.with_jti = True
1180+
if lifetime:
1181+
_jwt.lifetime = lifetime
11751182
return _jwt.pack(arq.to_dict(), owner=issuer, recv=recv)
11761183

11771184

src/oidcmsg/storage/extension.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def __getitem__(self, k):
4747
def __setitem__(self, k, v):
4848
return self.storage.set(k, v)
4949

50+
@key_label
51+
def set(self, k, v):
52+
return self.storage.set(k, v)
53+
5054
@key_label
5155
def __delitem__(self, k):
5256
del self.storage[k]

src/oidcmsg/storage/init.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def init_storage(db_conf=None, key='default'):
5858
"""
5959

6060
if db_conf:
61-
return storage_factory(get_storage_conf(db_conf, key))
62-
else:
63-
return LabeledDict({'label': key})
61+
_conf = get_storage_conf(db_conf, key)
62+
if _conf:
63+
return storage_factory(_conf)
64+
65+
return LabeledDict({'label': key})

tests/test_05_oauth2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
from oidcmsg.oauth2 import AuthorizationResponse
1919
from oidcmsg.oauth2 import CCAccessTokenRequest
2020
from oidcmsg.oauth2 import RefreshAccessTokenRequest
21-
from oidcmsg.oauth2 import TokenExchangeRequest
22-
from oidcmsg.oauth2 import TokenExchangeResponse
2321
from oidcmsg.oauth2 import ResponseMessage
2422
from oidcmsg.oauth2 import ROPCAccessTokenRequest
2523
from oidcmsg.oauth2 import TokenErrorResponse
24+
from oidcmsg.oauth2 import TokenExchangeRequest
25+
from oidcmsg.oauth2 import TokenExchangeResponse
2626
from oidcmsg.oauth2 import factory
2727
from oidcmsg.oauth2 import is_error_message
2828

0 commit comments

Comments
 (0)