Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions src/oidcop/token/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,42 @@ def factory(
TTYPE = {"code": "A", "token": "T", "refresh": "R"}

key_defs = []
read_only = False
if kwargs.get('jwks_def'):
defs = kwargs['jwks_def']
jwks_file = defs.get('private_path', jwks_file)
read_only = defs.get('read_only', read_only)
key_defs = defs.get('key_defs', [])

for _keyd in key_defs:
if _keyd['kid'] == 'code':
code = _keyd
elif _keyd['kid'] == 'refresh':
refresh = _keyd
elif _keyd['kid'] == 'token':
token = _keyd

if code is not None:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohe
should it be if not code instead?

if these definitions already have been configured in the general conf, why should we have to overwrite them?
they would be created if those arguments are None and also configuration's key_defs are None.

Do you agree?
If it's the way Give me a sign of this, I'll push a PR for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, you've already achieved this here
062dc1d

well done.

key_defs.append({"type": "oct", "bytes": 24, "use": ["enc"], "kid": "code"})
key_defs.append(
{"type": "oct", "bytes": 24, "use": ["enc"], "kid": "code"}
)
if refresh is not None:
key_defs.append({"type": "oct", "bytes": 24, "use": ["enc"], "kid": "refresh"})
key_defs.append(
{"type": "oct", "bytes": 24, "use": ["enc"], "kid": "refresh"}
)
if token is not None:
key_defs.append({"type": "oct", "bytes": 24, "use": ["enc"], "kid": "token"})
key_defs.append(
{"type": "oct", "bytes": 24, "use": ["enc"], "kid": "token"}
)

kj = init_key_jar(key_defs=key_defs, private_path=jwks_file, read_only=False)
kj = init_key_jar(key_defs=key_defs, private_path=jwks_file, read_only=read_only)

args = {}

if code:
_add_passwd(kj, code, "code")
args["code_handler"] = init_token_handler(server_get, code, TTYPE["code"])
args["code_handler"] = init_token_handler(
server_get, code, TTYPE["code"]
)

if token:
_add_passwd(kj, token, "token")
Expand Down