Skip to content

Commit e42abb8

Browse files
authored
Merge pull request #36 from IdentityPython/default_request_args
Default request arguments should be part of the service specific configuration
2 parents 98f7a67 + 366ef67 commit e42abb8

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/idpyoidc/client/entity.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __init__(
126126
jwks_uri = jwks_uri or self.get_metadata_value("jwks_uri")
127127
set_jwks_uri_or_jwks(self, self._service_context, config, jwks_uri, _kj)
128128

129-
# Deal with backward compatible
129+
# Deal with backward compatibility
130130
self.backward_compatibility(config)
131131

132132
self.construct_uris(self._service_context.issuer,
@@ -351,6 +351,11 @@ def backward_compatibility(self, config):
351351
"usage", "services", "add_ons"]:
352352
self.extra[key] = val
353353

354+
auth_request_args = config.conf.get("request_args", {})
355+
if auth_request_args:
356+
authz_serv = self.get_service('authorization')
357+
authz_serv.default_request_args.update(auth_request_args)
358+
354359
def config_args(self):
355360
res = {}
356361
for id, service in self._service.items():

src/idpyoidc/client/oidc/authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Authorization(authorization.Authorization):
3232

3333
def __init__(self, client_get, conf=None):
3434
authorization.Authorization.__init__(self, client_get, conf=conf)
35-
self.default_request_args = {"scope": ["openid"]}
35+
self.default_request_args.update({"scope": ["openid"]})
3636
self.pre_construct = [
3737
self.set_state,
3838
pre_construct_pick_redirect_uri,

src/idpyoidc/client/service.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ def __init__(
113113
elif def_val is not None:
114114
self.usage[param] = def_val
115115

116+
_default_request_args = conf.get("request_args", {})
117+
if _default_request_args:
118+
self.default_request_args = _default_request_args
119+
del conf["request_args"]
120+
116121
else:
117122
self.conf = {}
118123

@@ -164,6 +169,10 @@ def gather_request_args(self, **kwargs):
164169
if val:
165170
ar_args[prop] = val
166171

172+
for key, val in self.default_request_args.items():
173+
if key not in ar_args:
174+
ar_args[key] = val
175+
167176
return ar_args
168177

169178
def method_args(self, context, **kwargs):

0 commit comments

Comments
 (0)