This repository was archived by the owner on Jun 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path__init__.py
More file actions
executable file
·61 lines (43 loc) · 1.42 KB
/
__init__.py
File metadata and controls
executable file
·61 lines (43 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import hashlib
import string
# Since SystemRandom is not available on all systems
try:
import SystemRandom as rnd
except ImportError:
import random as rnd
__author__ = 'Roland Hedberg'
__version__ = '1.2.0'
OIDCONF_PATTERN = "{}/.well-known/openid-configuration"
CC_METHOD = {
'S256': hashlib.sha256,
'S384': hashlib.sha384,
'S512': hashlib.sha512,
}
# Map the signing context to a signing algorithm
DEF_SIGN_ALG = {"id_token": "RS256",
"userinfo": "RS256",
"request_object": "RS256",
"client_secret_jwt": "HS256",
"private_key_jwt": "RS256"}
HTTP_ARGS = ["headers", "redirections", "connection_type"]
JWT_BEARER = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
SAML2_BEARER_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:saml2-bearer"
BASECHR = string.ascii_letters + string.digits
def rndstr(size=16):
"""
Returns a string of random ascii characters or digits
:param size: The length of the string
:return: string
"""
return "".join([rnd.choice(BASECHR) for _ in range(size)])
BASECH = string.ascii_letters + string.digits + '-._~'
def unreserved(size=64):
"""
Returns a string of random ascii characters, digits and unreserved
characters
:param size: The length of the string
:return: string
"""
return "".join([rnd.choice(BASECH) for _ in range(size)])
def sanitize(str):
return str