Skip to content

Commit 8a6522f

Browse files
committed
Merge branch 'issuer_metadata' of https://github.com/IdentityPython/idpy-oidc into issuer_metadata
2 parents 89e2967 + 0941ab1 commit 8a6522f

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

src/idpyoidc/client/oauth2/add_on/par.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import logging
22

3+
from cryptojwt import JWT
34
from cryptojwt.utils import importer
45

56
from idpyoidc.client.client_auth import CLIENT_AUTHN_METHOD
7+
from idpyoidc.client.service import Service
68
from idpyoidc.message import Message
79
from idpyoidc.message.oauth2 import JWTSecuredAuthorizationRequest
810
from idpyoidc.server.util import execute
@@ -13,7 +15,7 @@
1315
HTTP_METHOD = "POST"
1416

1517

16-
def push_authorization(request_args, service, **kwargs):
18+
def push_authorization(request_args: Message, service: Service, **kwargs):
1719
"""
1820
:param request_args: All the request arguments as a AuthorizationRequest instance
1921
:param service: The service to which this post construct method is applied.
@@ -48,8 +50,15 @@ def push_authorization(request_args, service, **kwargs):
4850
)
4951
_headers["Content-Type"] = "application/x-www-form-urlencoded"
5052

53+
# construct a signed request object
54+
_jwt = JWT(key_jar=_context.keyjar)
55+
_request_object = _jwt.pack(request_args)
56+
5157
# construct the message body
52-
_body = request_args.to_urlencoded()
58+
_required_params = {k: v for k, v in request_args.items() if k in request_args.required_parameters()}
59+
_required_params["request"] = _request_object
60+
_req = service.msg_type(**_required_params)
61+
_body = _req.to_urlencoded()
5362

5463
_http_client = method_args.get("http_client", None)
5564
if not _http_client:

src/idpyoidc/client/util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ def get_deserialization_method(reqresp):
271271
return "jwt"
272272
except Exception:
273273
return "urlencoded" # reasonable default ??
274+
elif ';' in _ctype:
275+
for _typ in _ctype.split(";"):
276+
if _typ.startswith("application") or _typ.startswith("text"):
277+
_ctype = _typ
278+
break
274279

275280
if match_to_("application/json", _ctype) or match_to_("application/jrd+json", _ctype):
276281
deser_method = "json"

src/idpyoidc/storage/abfile.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ def synch(self):
239239
else:
240240
self.fmtime[f] = mtime
241241

242+
_keys = self.storage.keys()
243+
for f in _keys:
244+
fname = os.path.join(self.fdir, f)
245+
if os.path.isfile(fname):
246+
pass
247+
else:
248+
del self.storage[f]
249+
242250
def items(self):
243251
"""
244252
Implements the dict.items() method

src/idpyoidc/storage/listfile.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,43 @@ def _read_info(self, fname):
137137

138138
def __call__(self):
139139
return self._read_info(self.file_name)
140+
141+
class ReadWriteListFile(object):
142+
143+
def __init__(self, file_name):
144+
self.file_name = file_name
145+
146+
if not os.path.exists(file_name):
147+
fp = open(file_name, "x")
148+
fp.close()
149+
150+
def __contains__(self, item):
151+
_lst = self._read_info(self.file_name)
152+
return item in _lst
153+
154+
def __len__(self):
155+
_lst = self._read_info(self.file_name)
156+
if _lst is None or _lst == []:
157+
return 0
158+
159+
return len(_lst)
160+
161+
def _read_info(self, fname):
162+
if os.path.isfile(fname):
163+
try:
164+
lock = FileLock(f"{fname}.lock")
165+
with lock:
166+
fp = open(fname, "r")
167+
info = [x.strip() for x in fp.readlines()]
168+
lock.release()
169+
return info or None
170+
except Exception as err:
171+
logger.error(err)
172+
raise
173+
else:
174+
_msg = f"No such file: '{fname}'"
175+
logger.error(_msg)
176+
return None
177+
178+
def __call__(self):
179+
return self._read_info(self.file_name)

0 commit comments

Comments
 (0)