def _keyjar(self, keyjar=None, db_conf=None, conf=None, entity_id=''):
        if keyjar is None:
            _storage = None
            if db_conf:
                _cnf = get_storage_conf(db_conf, 'keyjar')
                if _cnf:
                    _storage = storage_factory(_cnf)

            if 'keys' in conf:
                args = {k: v for k, v in conf["keys"].items() if k != "uri_path"}
                args.update({'storage': _storage})
                _keyjar = init_key_jar(**args)
            else:
                _keyjar = KeyJar(storage=_storage)
                if 'jwks' in conf:
                    _keyjar.import_jwks(conf['jwks'], '')

            if '' in _keyjar and entity_id:
                # make sure I have the keys under my own name too (if I know it)
                _keyjar.import_jwks_as_json(_keyjar.export_jwks_as_json(True, ''), entity_id)

            _httpc_params = conf.get('httpc_params')
            if _httpc_params:
                _keyjar.httpc_params = _httpc_params

            return _keyjar
        else:
            return keyjar
    def _keyjar(self, keyjar=None, conf=None, entity_id=""):
        if keyjar is None:
            if "keys" in conf:
                keys_args = {
                    k: v
                    for k, v in conf["keys"].items() if k != "uri_path"
                }
                _keyjar = init_key_jar(**keys_args)
            elif "key_conf" in conf:
                keys_args = {
                    k: v
                    for k, v in conf["key_conf"].items() if k != "uri_path"
                }
                _keyjar = init_key_jar(**keys_args)
            else:
                _keyjar = KeyJar()
                if "jwks" in conf:
                    _keyjar.import_jwks(conf["jwks"], "")

            if "" in _keyjar and entity_id:
                # make sure I have the keys under my own name too (if I know it)
                _keyjar.import_jwks_as_json(
                    _keyjar.export_jwks_as_json(True, ""), entity_id)

            _httpc_params = conf.get("httpc_params")
            if _httpc_params:
                _keyjar.httpc_params = _httpc_params

            return _keyjar
        else:
            return keyjar
Esempio n. 3
0
def init_oidc_rp_handler(app):
    _rp_conf = app.rp_config

    if _rp_conf.rp_keys:
        _kj = init_key_jar(**_rp_conf.rp_keys)
        _path = _rp_conf.rp_keys['public_path']
        # removes ./ and / from the begin of the string
        _path = re.sub('^(.)/', '', _path)
    else:
        _kj = KeyJar()
        _path = ''
    _kj.httpc_params = _rp_conf.httpc_params

    rph = RPHandler(_rp_conf.base_url, _rp_conf.clients, services=_rp_conf.services,
                    hash_seed=_rp_conf.hash_seed, keyjar=_kj, jwks_path=_path,
                    httpc_params=_rp_conf.httpc_params)

    return rph
Esempio n. 4
0
def init_oidc_rp_handler(app):
    _rp_conf = app.config

    if _rp_conf.get('rp_keys'):
        _kj = init_key_jar(**_rp_conf['rp_keys'])
        _path = _rp_conf['rp_keys']['public_path']
        # removes ./ and / from the begin of the string
        _path = re.sub('^(.)/', '', _path)
    else:
        _kj = KeyJar()
        _path = ''
    _kj.httpc_params = _rp_conf['httpc_params']
    hash_seed = app.config.get('hash_seed', "BabyHoldOn")
    rph = RPHandler(_rp_conf['base_url'], _rp_conf['clients'], services=_rp_conf['services'],
                    hash_seed=hash_seed, keyjar=_kj, jwks_path=_path,
                    httpc_params=_rp_conf['httpc_params']) #, verify_ssl=False)

    return rph