Skip to content

Commit fd283e2

Browse files
authored
Merge pull request #117 from IdentityPython/arg_info-key_import
key_import and alg_info
2 parents 82b6e8f + 421e211 commit fd283e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+617
-713
lines changed

demo/oauth2_add_on_dpop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from common import KEYDEFS
66
from common import full_path
77
from flow import Flow
8-
from idpyoidc.metadata import get_signing_algs
8+
from idpyoidc.alg_info import get_signing_algs
99
from idpyoidc.client.oauth2 import Client
1010
from idpyoidc.server import Server
1111
from idpyoidc.server.configure import ASConfiguration

private/xmetadata/oidc.py

Lines changed: 0 additions & 127 deletions
This file was deleted.

src/idpyoidc/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "Roland Hedberg"
2-
__version__ = "4.3.0"
2+
__version__ = "5.0.0"
33

44
VERIFIED_CLAIM_PREFIX = "__verified"
55

@@ -10,7 +10,7 @@ def verified_claim_name(claim):
1010

1111
def proper_path(path):
1212
"""
13-
Clean up the path specification so it looks like something I could use.
13+
Clean up the path specification such that it looks like something I could use.
1414
"./" <path> "/"
1515
"""
1616
if path.startswith("./"):

src/idpyoidc/alg_info.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from functools import cmp_to_key
2+
import logging
3+
4+
from cryptojwt.jwe import DEPRECATED
5+
from cryptojwt.jwe import SUPPORTED
6+
from cryptojwt.jws.jws import SIGNER_ALGS
7+
8+
logger = logging.getLogger(__name__)
9+
10+
SIGNING_ALGORITHM_SORT_ORDER = ["RS", "ES", "PS", "HS", "Ed"]
11+
12+
13+
def cmp(a, b):
14+
return (a > b) - (a < b)
15+
16+
17+
def alg_cmp(a, b):
18+
if a == "none":
19+
return 1
20+
elif b == "none":
21+
return -1
22+
23+
_pos1 = SIGNING_ALGORITHM_SORT_ORDER.index(a[0:2])
24+
_pos2 = SIGNING_ALGORITHM_SORT_ORDER.index(b[0:2])
25+
if _pos1 == _pos2:
26+
return (a > b) - (a < b)
27+
elif _pos1 > _pos2:
28+
return 1
29+
else:
30+
return -1
31+
32+
33+
def get_signing_algs():
34+
# Assumes Cryptojwt
35+
_algs = [name for name in list(SIGNER_ALGS.keys()) if name != "none" and name not in DEPRECATED["alg"]]
36+
return sorted(_algs, key=cmp_to_key(alg_cmp))
37+
38+
39+
def get_encryption_algs():
40+
return SUPPORTED["alg"]
41+
42+
43+
def get_encryption_encs():
44+
return SUPPORTED["enc"]
45+
46+
47+
def array_or_singleton(claim_spec, values):
48+
if isinstance(claim_spec[0], list):
49+
if isinstance(values, list):
50+
return values
51+
else:
52+
return [values]
53+
else:
54+
if isinstance(values, list):
55+
return values[0]
56+
else: # singleton
57+
return values
58+
59+
60+
def is_subset(a, b):
61+
if isinstance(a, list):
62+
if isinstance(b, list):
63+
return set(b).issubset(set(a))
64+
elif isinstance(b, list):
65+
return a in b
66+
else:
67+
return a == b

0 commit comments

Comments
 (0)