REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.87 KB
Close
//opt/alt/python37/lib/python3.7/site-packages/jwt/api_jwk.py
Text
Base64
import json from .algorithms import get_default_algorithms from .exceptions import InvalidKeyError, PyJWKError, PyJWKSetError class PyJWK: def __init__(self, jwk_data, algorithm=None): self._algorithms = get_default_algorithms() self._jwk_data = jwk_data kty = self._jwk_data.get("kty", None) if not kty: raise InvalidKeyError("kty is not found: %s" % self._jwk_data) if not algorithm and isinstance(self._jwk_data, dict): algorithm = self._jwk_data.get("alg", None) if not algorithm: # Determine alg with kty (and crv). crv = self._jwk_data.get("crv", None) if kty == "EC": if crv == "P-256" or not crv: algorithm = "ES256" elif crv == "P-384": algorithm = "ES384" elif crv == "P-521": algorithm = "ES512" elif crv == "secp256k1": algorithm = "ES256K" else: raise InvalidKeyError("Unsupported crv: %s" % crv) elif kty == "RSA": algorithm = "RS256" elif kty == "oct": algorithm = "HS256" elif kty == "OKP": if not crv: raise InvalidKeyError("crv is not found: %s" % self._jwk_data) if crv == "Ed25519": algorithm = "EdDSA" else: raise InvalidKeyError("Unsupported crv: %s" % crv) else: raise InvalidKeyError("Unsupported kty: %s" % kty) self.Algorithm = self._algorithms.get(algorithm) if not self.Algorithm: raise PyJWKError("Unable to find a algorithm for key: %s" % self._jwk_data) self.key = self.Algorithm.from_jwk(self._jwk_data) @staticmethod def from_dict(obj, algorithm=None): return PyJWK(obj, algorithm) @staticmethod def from_json(data, algorithm=None): obj = json.loads(data) return PyJWK.from_dict(obj, algorithm) @property def key_type(self): return self._jwk_data.get("kty", None) @property def key_id(self): return self._jwk_data.get("kid", None) @property def public_key_use(self): return self._jwk_data.get("use", None) class PyJWKSet: def __init__(self, keys): self.keys = [] if not keys or not isinstance(keys, list): raise PyJWKSetError("Invalid JWK Set value") if len(keys) == 0: raise PyJWKSetError("The JWK Set did not contain any keys") for key in keys: self.keys.append(PyJWK(key)) @staticmethod def from_dict(obj): keys = obj.get("keys", []) return PyJWKSet(keys) @staticmethod def from_json(data): obj = json.loads(data) return PyJWKSet.from_dict(obj)
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 10
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__pycache__
DIR
-
drwxr-xr-x
2024-03-03 23:14:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
algorithms.py
20.97 KB
lrw-r--r--
2021-04-28 11:43:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
api_jwk.py
2.87 KB
lrw-r--r--
2021-04-28 11:23:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
api_jws.py
7.65 KB
lrw-r--r--
2020-12-21 16:55:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
api_jwt.py
7.13 KB
lrw-r--r--
2021-04-28 11:23:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
exceptions.py
965 B
lrw-r--r--
2020-08-24 16:22:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
help.py
1.57 KB
lrw-r--r--
2020-12-21 16:55:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
jwks_client.py
1.88 KB
lrw-r--r--
2021-04-28 11:23:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
py.typed
0 B
lrw-r--r--
2020-12-20 00:01:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
utils.py
2.45 KB
lrw-r--r--
2020-12-21 16:55:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
1.52 KB
lrw-r--r--
2021-04-28 11:59:20
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).