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

Commit 6a86832

Browse files
committed
Static provider keys should be stored in the clients service_context.
1 parent 2600ff6 commit 6a86832

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/oidcrp/__init__.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,19 @@ def do_provider_info(self, client=None, state=''):
241241
_srv.endpoint = val
242242

243243
if 'keys' in _pi:
244+
_kj = client.service_context.keyjar
244245
for typ, _spec in _pi['keys'].items():
245246
if typ == 'url':
246247
for _iss, _url in _spec.items():
247-
self.keyjar.add_url(_iss, _url)
248+
_kj.add_url(_iss, _url)
248249
elif typ == 'file':
249250
for kty, _name in _spec.items():
250251
if kty == 'jwks':
251-
self.keyjar.import_jwks_from_file(_name,
252-
client.service_context.issuer)
252+
_kj.import_jwks_from_file(_name,
253+
client.service_context.issuer)
253254
elif kty == 'rsa': # PEM file
254255
_kb = keybundle_from_local_file(_name, "der", ["sig"])
255-
self.keyjar.add_kb(client.service_context.issuer, _kb)
256+
_kj.add_kb(client.service_context.issuer, _kb)
256257
else:
257258
raise ValueError('Unknown provider JWKS type: {}'.format(typ))
258259
try:
@@ -373,7 +374,7 @@ def create_callbacks(self, issuer):
373374
'implicit': "{}/authz_im_cb/{}".format(self.base_url, _hex),
374375
'form_post': "{}/authz_fp_cb/{}".format(self.base_url, _hex),
375376
'__hex': _hex
376-
}
377+
}
377378

378379
def init_authorization(self, client=None, state='', req_args=None):
379380
"""
@@ -400,7 +401,7 @@ def init_authorization(self, client=None, state='', req_args=None):
400401
'scope': service_context.behaviour['scope'],
401402
'response_type': service_context.behaviour['response_types'][0],
402403
'nonce': _nonce
403-
}
404+
}
404405

405406
if req_args is not None:
406407
request_args.update(req_args)
@@ -509,15 +510,15 @@ def get_access_token(self, state, client=None):
509510
'grant_type': 'authorization_code',
510511
'client_id': client.service_context.client_id,
511512
'client_secret': client.service_context.client_secret
512-
}
513+
}
513514
logger.debug('request_args: {}'.format(req_args))
514515
try:
515516
tokenresp = client.do_request(
516517
'accesstoken', request_args=req_args,
517518
authn_method=self.get_client_authn_method(client,
518519
"token_endpoint"),
519520
state=state
520-
)
521+
)
521522
except Exception as err:
522523
message = traceback.format_exception(*sys.exc_info())
523524
logger.error(message)
@@ -553,7 +554,7 @@ def refresh_access_token(self, state, client=None, scope=''):
553554
authn_method=self.get_client_authn_method(client,
554555
"token_endpoint"),
555556
state=state, request_args=req_args
556-
)
557+
)
557558
except Exception as err:
558559
message = traceback.format_exception(*sys.exc_info())
559560
logger.error(message)
@@ -730,7 +731,7 @@ def finalize(self, issuer, response):
730731
return {
731732
'state': authorization_response['state'],
732733
'error': authorization_response['error']
733-
}
734+
}
734735

735736
_state = authorization_response['state']
736737
token = self.get_access_and_id_token(authorization_response,
@@ -745,7 +746,7 @@ def finalize(self, issuer, response):
745746
return {
746747
'error': "Invalid response %s." % inforesp["error"],
747748
'state': _state
748-
}
749+
}
749750

750751
elif token['id_token']: # look for it in the ID Token
751752
inforesp = self.userinfo_in_id_token(token['id_token'])
@@ -780,7 +781,7 @@ def finalize(self, issuer, response):
780781
'state': authorization_response['state'],
781782
'token': token['access_token'],
782783
'id_token': token['id_token']
783-
}
784+
}
784785

785786
def has_active_authentication(self, state):
786787
"""
@@ -869,7 +870,7 @@ def logout(self, state, client=None, post_logout_redirect_uri=''):
869870
if post_logout_redirect_uri:
870871
request_args = {
871872
"post_logout_redirect_uri": post_logout_redirect_uri
872-
}
873+
}
873874
else:
874875
request_args = {}
875876

@@ -899,7 +900,7 @@ def backchannel_logout(client, request='', request_args=None):
899900
'aud': client.service_context.client_id,
900901
'iss': client.service_context.issuer,
901902
'keyjar': client.service_context.keyjar
902-
}
903+
}
903904

904905
try:
905906
req.verify(**kwargs)

0 commit comments

Comments
 (0)