blob: 61f7133274d44785510da94d58664012be7c6971 (
plain) (
blame)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
import jwt
from datetime import datetime, timedelta
# from cryptography.hazmat.primitives import serialization
# from cryptography.hazmat.primitives.serialization import load_pem_private_key
# from cryptography.hazmat.backends import default_backend
def do_jwt(json_data: dict):
private_key = b'''-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEAxv9TLZP2TnsR512LqzT52N6Z9ixKmUA11jy0IXH0dEbdbfBw
eeWrXoTuIYcY8Dkg/+q33ppfujYfb0z22bs/CZ63+jBL2UmxG/0XIzmsQlHSgJd/
rnbERwIt7/ZjOHAcNrAzI0N11AI8AT0+M3XFOGRoIKzoc3Juxl7eyyPPEkNZMkEv
lYfDN5AMD/+4pZ+7SCEzUCyGtBejW2P+NwTvjBxhLjIoG+m7yh81RoIBnO+Z1o5X
ZtospuWZe1L6GNh+zezeHIyBGYgGgYbPboQ8QeHhoh+n0PuZB0GQqorqfxHjB38t
yB4qsRGi10UNcohvFhglZk8kdMYBTd0M5ik5t4sx/ujjF57gX7dCKipHimDy7McY
ElVLTDoSkwD/Lg3tV0utky42dL/iIMePlHfMrw/m2oAm33/dCaiAW8grNkJPjcwo
Y8pnqpFGgAZX+6WalQCfoSStV4kYYlaq11DB6dZjDYoKLRIyH7MCAmMxms9569qe
5gFuyQWTZgXlKoj2Zd7XIaIs5s/A6PFt7sxk8mOY/DspSbygZZCnMH3+or/8trH2
p0fGEkqpzMKAY6TYtdYhOyTbup3VOKQwhk8b5CPuEWZutE6pT0O2O81MkuEEl/Zw
/M1MJERTIjGAThsL0yvEn1Gi5HXl7s/5E61Yvc0ItORqio70PZcToRII27ECAwEA
AQKCAgEAle0H3e78Q2S1uHriH7tqAd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5yy/pXrNzLi0LfpmFzxbChfO8ai
omC/oqxU0FKqY2msFYdnfwM3PZeZ3c7LALLhWG56/fIYMtV78+cfqkRPM8nRJXaF
Aza2YTTZGfh3x10KnSLWUmhIWUEj8VzCNW7SR0Ecqa+ordAYio4wBsq7sO3sCw8G
Oi0/98ondhGJWL3M6FDGai8dXewt+8o0dlq95mHkNNopCWbPI71pM7u4ABPL50Yd
spd4eADxTm2m0GR7bhVEIbYfc0aAzIoWDpVs4V3vmx+bdRbppFxV1aS/r0g=
-----END RSA PRIVATE KEY-----'''
header = {
'alg': 'RS256',
'typ': 'JWT',
'kid': '1c8a5da7-527e-4bee-aa8d-aabda16c59ce'
}
payload = {
**json_data,
'iat': int(datetime.now().timestamp()),
'exp': int((datetime.now() + timedelta(minutes=10)).timestamp()),
'iss': 'https://rick.roll'
}
return jwt.encode(payload, private_key, algorithm='RS256', headers=header)
|