Linux vmi2545633.contaboserver.net 6.1.0-32-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.129-1 (2025-03-06) x86_64
Apache/2.4.62 (Debian)
Server IP : 127.0.0.1 & Your IP : 127.0.0.1
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
lib /
python3 /
dist-packages /
jwt /
Delete
Unzip
Name
Size
Permission
Date
Action
__pycache__
[ DIR ]
drwxr-xr-x
2025-04-07 20:41
__init__.py
1.57
KB
-rw-r--r--
2022-10-20 01:08
algorithms.py
23.13
KB
-rw-r--r--
2022-09-20 10:55
api_jwk.py
3.57
KB
-rw-r--r--
2022-09-20 10:55
api_jws.py
10.4
KB
-rw-r--r--
2022-09-20 11:00
api_jwt.py
9.82
KB
-rw-r--r--
2022-10-20 00:40
exceptions.py
963
B
-rw-r--r--
2022-05-12 18:31
help.py
1.65
KB
-rw-r--r--
2022-09-20 10:55
jwk_set_cache.py
944
B
-rw-r--r--
2022-09-20 10:55
jwks_client.py
3.47
KB
-rw-r--r--
2022-09-20 10:55
py.typed
0
B
-rw-r--r--
2020-12-20 00:01
utils.py
3.88
KB
-rw-r--r--
2022-09-20 10:55
warnings.py
59
B
-rw-r--r--
2022-09-20 10:55
Save
Rename
from __future__ import annotations import json import time 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(f"kty is not found: {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(f"Unsupported crv: {crv}") elif kty == "RSA": algorithm = "RS256" elif kty == "oct": algorithm = "HS256" elif kty == "OKP": if not crv: raise InvalidKeyError(f"crv is not found: {self._jwk_data}") if crv == "Ed25519": algorithm = "EdDSA" else: raise InvalidKeyError(f"Unsupported crv: {crv}") else: raise InvalidKeyError(f"Unsupported kty: {kty}") self.Algorithm = self._algorithms.get(algorithm) if not self.Algorithm: raise PyJWKError(f"Unable to find a algorithm for key: {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: list[dict]) -> None: self.keys = [] if not keys: raise PyJWKSetError("The JWK Set did not contain any keys") if not isinstance(keys, list): raise PyJWKSetError("Invalid JWK Set value") for key in keys: try: self.keys.append(PyJWK(key)) except PyJWKError: # skip unusable keys continue if len(self.keys) == 0: raise PyJWKSetError("The JWK Set did not contain any usable keys") @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) def __getitem__(self, kid): for key in self.keys: if key.key_id == kid: return key raise KeyError(f"keyset has no key for kid: {kid}") class PyJWTSetWithTimestamp: def __init__(self, jwk_set: PyJWKSet): self.jwk_set = jwk_set self.timestamp = time.monotonic() def get_jwk_set(self): return self.jwk_set def get_timestamp(self): return self.timestamp