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

Commit 96cb50f

Browse files
committed
get_token_handlers as a standalone function
1 parent 85d91e3 commit 96cb50f

1 file changed

Lines changed: 23 additions & 22 deletions

File tree

src/oidcendpoint/endpoint_context.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,28 @@ def init_service(conf, endpoint_context=None):
121121
return conf["class"](**kwargs)
122122

123123

124+
def get_token_handlers(conf):
125+
th_args = conf.get("token_handler_args", None)
126+
if not th_args:
127+
# create 3 keys
128+
keydef = [
129+
{"type": "oct", "bytes": "24", "use": ["enc"], "kid": "code"},
130+
{"type": "oct", "bytes": "24", "use": ["enc"], "kid": "token"},
131+
{"type": "oct", "bytes": "24", "use": ["enc"], "kid": "refresh"},
132+
]
133+
134+
jwks_def = {
135+
"private_path": "private/token_jwks.json",
136+
"key_defs": keydef,
137+
"read_only": False,
138+
}
139+
th_args = {"jwks_def": jwks_def}
140+
for typ, tid in [("code", 600), ("token", 3600), ("refresh", 86400)]:
141+
th_args[typ] = {"lifetime": tid}
142+
143+
return th_args
144+
145+
124146
class EndpointContext:
125147
def __init__(
126148
self,
@@ -331,29 +353,8 @@ def do_sub_func(self, conf):
331353
else:
332354
self._sub_func[key] = args["function"]
333355

334-
def get_token_handlers(self, conf):
335-
th_args = conf.get("token_handler_args", None)
336-
if not th_args:
337-
# create 3 keys
338-
keydef = [
339-
{"type": "oct", "bytes": "24", "use": ["enc"], "kid": "code"},
340-
{"type": "oct", "bytes": "24", "use": ["enc"], "kid": "token"},
341-
{"type": "oct", "bytes": "24", "use": ["enc"], "kid": "refresh"},
342-
]
343-
344-
jwks_def = {
345-
"private_path": "private/token_jwks.json",
346-
"key_defs": keydef,
347-
"read_only": False,
348-
}
349-
th_args = {"jwks_def": jwks_def}
350-
for typ, tid in [("code", 600), ("token", 3600), ("refresh", 86400)]:
351-
th_args[typ] = {"lifetime": tid}
352-
353-
return th_args
354-
355356
def do_session_db(self, conf):
356-
th_args = self.get_token_handlers(conf)
357+
th_args = get_token_handlers(conf)
357358
self.sdb = create_session_db(
358359
self, th_args, db=None, sso_db=SSODb(), sub_func=self._sub_func
359360
)

0 commit comments

Comments
 (0)