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

Commit d288d64

Browse files
committed
Function for reading http client arguments from configuration.
1 parent 9389042 commit d288d64

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/oidcendpoint/endpoint_context.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from oidcendpoint.user_authn.authn_context import populate_authn_broker
2020
from oidcendpoint.user_info import SCOPE2CLAIMS
2121
from oidcendpoint.util import build_endpoints
22+
from oidcendpoint.util import get_http_params
2223
from oidcendpoint.util import importer
2324

2425
logger = logging.getLogger(__name__)
@@ -232,15 +233,11 @@ def __init__(
232233
self.registration_access_token = {}
233234

234235
# The HTTP clients request arguments
235-
_verify = conf.get('verify_ssl', True)
236-
self.httpc_params= {'verify': _verify}
237-
238-
_cli_cert = conf.get("client_cert")
239-
_cli_key = conf.get("client_key")
240-
if _cli_cert and _cli_key:
241-
self.httpc_params["cert"] = (_cli_cert, _cli_key)
242-
elif _cli_cert: # The file contains both the certificate and the key
243-
self.httpc_params["cert"] = _cli_cert
236+
_cnf = conf.get("http_params")
237+
if _cnf:
238+
self.httpc_params= get_http_params(_cnf)
239+
else: # Backward compatibility
240+
self.httpc_params = {"verify": conf.get("verify_ssl")}
244241

245242
def set_session_db(self, sso_db=None, db=None):
246243
sso_db = sso_db or SSODb()

src/oidcendpoint/util.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,17 @@ def lv_unpack(txt):
130130
res.append(v[: int(l)])
131131
txt = v[int(l) :]
132132
return res
133+
134+
135+
def get_http_params(config):
136+
params = {"verify": config.get('verify_ssl')}
137+
_cert = config.get('client_cert')
138+
_key = config.get('client_key')
139+
if _cert:
140+
if _key:
141+
params['cert'] = (_cert, _key)
142+
else:
143+
params['cert'] = _cert
144+
145+
return params
146+

0 commit comments

Comments
 (0)