Coverage for /usr/local/lib/python3.10/site-packages/opal_common-0.0.0-py3.10.egg/opal_common/authentication/types.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-10 11:54 +0000

1from enum import Enum 

2from typing import Any, Dict 

3 

4from cryptography.hazmat.primitives.asymmetric.types import ( 

5 PrivateKeyTypes, 

6 PublicKeyTypes, 

7) 

8from jwt.algorithms import get_default_algorithms 

9 

10# custom types 

11PrivateKey = PrivateKeyTypes 

12PublicKey = PublicKeyTypes 

13JWTClaims = Dict[str, Any] 

14 

15 

16class EncryptionKeyFormat(str, Enum): 

17 """Represent the supported formats for storing encryption keys. 

18 

19 - PEM (https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) 

20 - SSH (RFC4716) or short format (RFC4253, section-6.6, explained here: https://coolaj86.com/articles/the-ssh-public-key-format/) 

21 - DER (https://en.wikipedia.org/wiki/X.690#DER_encoding) 

22 """ 

23 

24 pem = "pem" 

25 ssh = "ssh" 

26 der = "der" 

27 

28 

29# dynamic enum because pyjwt does not define one 

30# see: https://pyjwt.readthedocs.io/en/stable/algorithms.html for possible values 

31JWTAlgorithm = Enum("JWTAlgorithm", [(k, k) for k in get_default_algorithms().keys()])