File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from cryptojwt .utils import importer
44
55from idpyoidc .client .client_auth import CLIENT_AUTHN_METHOD
6+ from idpyoidc .client .service import Service
67from idpyoidc .message import Message
78from idpyoidc .message .oauth2 import JWTSecuredAuthorizationRequest
89from idpyoidc .server .util import execute
1314HTTP_METHOD = "POST"
1415
1516
16- def push_authorization (request_args , service , ** kwargs ):
17+ def push_authorization (request_args : Message , service : Service , ** kwargs ):
1718 """
1819 :param request_args: All the request arguments as a AuthorizationRequest instance
1920 :param service: The service to which this post construct method is applied.
Original file line number Diff line number Diff 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"
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments