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

Commit 8dc7bf0

Browse files
committed
BREAKAGE: seed param moved from global configuration to registration endpoint
1 parent a01c7c1 commit 8dc7bf0

4 files changed

Lines changed: 25 additions & 20 deletions

File tree

doc/source/contents/conf.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ issuer
88

99
The issuer ID of the OP, a unique value in URI format.
1010

11-
----
12-
seed
13-
----
14-
15-
Used in dynamic client registration endpoint when creating a new client_secret.
16-
If unset it will be random.
1711

1812
--------
1913
password
@@ -209,8 +203,14 @@ An example::
209203
"path": "registration",
210204
"class": "oidcop.oidc.registration.Registration",
211205
"kwargs": {
212-
"client_authn_method": null,
213-
"client_secret_expiration_time": 432000
206+
"client_authn_method": None,
207+
"client_secret_expiration_time": 432000,
208+
"client_id_generator": {
209+
"class": 'oidcop.oidc.registration.random_client_id',
210+
"kwargs": {
211+
"seed": "that-optional-random-value"
212+
}
213+
}
214214
}
215215
},
216216
"registration_api": {

src/oidcop/configure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ def __init__(
221221
self.token_handler_args = {}
222222
self.userinfo = None
223223
self.password = None
224-
self.salt = None
225224

226225
if file_attributes is None:
227226
file_attributes = DEFAULT_FILE_ATTRIBUTE_NAMES

src/oidcop/endpoint_context.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import requests
88
from cryptojwt import KeyJar
9-
from cryptojwt.utils import as_bytes
109
from jinja2 import Environment
1110
from jinja2 import FileSystemLoader
1211
from oidcmsg.context import OidcContext
@@ -111,7 +110,6 @@ class EndpointContext(OidcContext):
111110
"provider_info": {},
112111
"registration_access_token": {},
113112
"scope2claims": {},
114-
"seed": "",
115113
# "session_db": {},
116114
"session_manager": SessionManager,
117115
"sso_ttl": None,
@@ -139,12 +137,6 @@ def __init__(
139137

140138
self.cwd = cwd
141139

142-
# Those that use seed wants bytes but I can only store str.
143-
try:
144-
self.seed = as_bytes(conf["seed"])
145-
except KeyError:
146-
self.seed = as_bytes(rndstr(32))
147-
148140
# Default values, to be changed below depending on configuration
149141
# arguments for endpoints add-ons
150142
self.args = {}

src/oidcop/oidc/registration.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,14 @@ def comb_uri(args):
9999
val = []
100100
for base, query_dict in args[param]:
101101
if query_dict:
102-
query_string = urlencode([(key, v) for key in query_dict for v in query_dict[key]])
103-
val.append("%s?%s" % (base, query_string))
102+
query_string = urlencode(
103+
[
104+
(key, v)
105+
for key in query_dict
106+
for v in query_dict[key]
107+
]
108+
)
109+
val.append("{base}?{query_string}")
104110
else:
105111
val.append(base)
106112

@@ -139,6 +145,14 @@ class Registration(Endpoint):
139145
# default
140146
# response_placement = 'body'
141147

148+
def __init__(self, *args, **kwargs):
149+
super().__init__(*args, **kwargs)
150+
151+
# Those that use seed wants bytes but I can only store str.
152+
# seed
153+
_seed = kwargs.get("seed") or rndstr(32)
154+
self.seed = as_bytes(_seed)
155+
142156
def match_client_request(self, request):
143157
_context = self.server_get("endpoint_context")
144158
for _pref, _prov in PREFERENCE2PROVIDER.items():
@@ -358,7 +372,7 @@ def client_secret_expiration_time(self):
358372
return utc_time_sans_frac() + _expiration_time
359373

360374
def add_client_secret(self, cinfo, client_id, context):
361-
client_secret = secret(context.seed, client_id)
375+
client_secret = secret(self.seed, client_id)
362376
cinfo["client_secret"] = client_secret
363377
_eat = self.client_secret_expiration_time()
364378
if _eat:

0 commit comments

Comments
 (0)