|
2 | 2 | import logging |
3 | 3 | import sys |
4 | 4 | import traceback |
5 | | -from importlib import import_module |
6 | 5 |
|
7 | | -from cryptojwt.utils import as_bytes, as_unicode |
8 | | -from oidcmsg.exception import MessageException, NotForMe |
| 6 | +from cryptojwt.key_bundle import keybundle_from_local_file |
| 7 | +from cryptojwt.utils import as_bytes |
| 8 | +from cryptojwt.utils import as_unicode |
| 9 | +from oidcmsg.exception import MessageException |
| 10 | +from oidcmsg.exception import NotForMe |
9 | 11 | from oidcmsg.oauth2 import ResponseMessage |
10 | 12 | from oidcmsg.oauth2 import is_error_message |
11 | | -from oidcmsg.oidc import AccessTokenResponse, verified_claim_name |
| 13 | +from oidcmsg.oidc import AccessTokenResponse |
12 | 14 | from oidcmsg.oidc import AuthorizationRequest |
13 | 15 | from oidcmsg.oidc import AuthorizationResponse |
14 | 16 | from oidcmsg.oidc import OpenIDSchema |
| 17 | +from oidcmsg.oidc import verified_claim_name |
15 | 18 | from oidcmsg.oidc.session import BackChannelLogoutRequest |
16 | 19 | from oidcmsg.time_util import time_sans_frac |
17 | 20 | from oidcservice import rndstr |
|
24 | 27 | from oidcrp import provider |
25 | 28 |
|
26 | 29 | __author__ = 'Roland Hedberg' |
27 | | -__version__ = '0.6.1' |
| 30 | +__version__ = '0.6.3' |
28 | 31 |
|
29 | 32 | logger = logging.getLogger(__name__) |
30 | 33 |
|
@@ -237,6 +240,22 @@ def do_provider_info(self, client=None, state=''): |
237 | 240 | if _srv.endpoint_name == key: |
238 | 241 | _srv.endpoint = val |
239 | 242 |
|
| 243 | + if 'keys' in _pi: |
| 244 | + _kj = client.service_context.keyjar |
| 245 | + for typ, _spec in _pi['keys'].items(): |
| 246 | + if typ == 'url': |
| 247 | + for _iss, _url in _spec.items(): |
| 248 | + _kj.add_url(_iss, _url) |
| 249 | + elif typ == 'file': |
| 250 | + for kty, _name in _spec.items(): |
| 251 | + if kty == 'jwks': |
| 252 | + _kj.import_jwks_from_file(_name, |
| 253 | + client.service_context.issuer) |
| 254 | + elif kty == 'rsa': # PEM file |
| 255 | + _kb = keybundle_from_local_file(_name, "der", ["sig"]) |
| 256 | + _kj.add_kb(client.service_context.issuer, _kb) |
| 257 | + else: |
| 258 | + raise ValueError('Unknown provider JWKS type: {}'.format(typ)) |
240 | 259 | try: |
241 | 260 | return client.service_context.provider_info['issuer'] |
242 | 261 | except KeyError: |
@@ -903,46 +922,3 @@ def backchannel_logout(client, request='', request_args=None): |
903 | 922 | _state = client.session_interface.get_state_by_sub(sub) |
904 | 923 |
|
905 | 924 | return _state |
906 | | - |
907 | | - |
908 | | -# def get_provider_specific_service(service_provider, service, **kwargs): |
909 | | -# """ |
910 | | -# Get a class instance of a :py:class:`oidcservice.service.Service` subclass |
911 | | -# specific to a specified service provider. |
912 | | -# |
913 | | -# :param service_provider: The name of the service provider |
914 | | -# :param service: The name of the service |
915 | | -# :param kwargs: Arguments provided when initiating the class |
916 | | -# :return: An initiated subclass of :py:class:`oidcservice.service.Service` |
917 | | -# or None if the service or the service provider could not be found. |
918 | | -# """ |
919 | | -# if service_provider in provider.__all__: |
920 | | -# mod = import_module('oidcrp.provider.' + service_provider) |
921 | | -# cls = getattr(mod, service) |
922 | | -# return cls(**kwargs) |
923 | | -# |
924 | | -# return None |
925 | | -# |
926 | | -# |
927 | | -# def factory(service_name, ignore, **kwargs): |
928 | | -# """ |
929 | | -# A factory the given a service name will return a |
930 | | -# :py:class:`oidcservice.service.Service` instance if a service matching the |
931 | | -# name could be found. |
932 | | -# |
933 | | -# :param service_name: A service name, could be either of the format |
934 | | -# 'group.name' or 'name'. |
935 | | -# :param kwargs: A set of key word arguments to be used when initiating the |
936 | | -# Service class |
937 | | -# :return: A :py:class:`oidcservice.service.Service` instance or None |
938 | | -# """ |
939 | | -# if '.' in service_name: |
940 | | -# group, name = service_name.split('.') |
941 | | -# if group == 'oauth2': |
942 | | -# service_factory(service_name[1], ['oauth2'], **kwargs) |
943 | | -# elif group == 'oidc': |
944 | | -# service_factory(service_name[1], ['oidc'], **kwargs) |
945 | | -# else: |
946 | | -# return get_provider_specific_service(group, name, **kwargs) |
947 | | -# else: |
948 | | -# return service_factory(service_name, ['oidc', 'oauth2'], **kwargs) |
0 commit comments