summaryrefslogtreecommitdiffstats
path: root/ora/_jwt.py
diff options
context:
space:
mode:
Diffstat (limited to 'ora/_jwt.py')
-rw-r--r--ora/_jwt.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/ora/_jwt.py b/ora/_jwt.py
new file mode 100644
index 00000000..cc8b2349
--- /dev/null
+++ b/ora/_jwt.py
@@ -0,0 +1,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/5E61Yvc0ItORqio70PZcToRII27ECAw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IBAGc6M8/FH1pLgxOgS6oEGJAtErxv
+EnmELzKvfwBryphx8f0S5sHoiqli+5dqFtw5h5yy/pXrNzLi0LfpmFzxbChfO8ai
+omC/oqxU0FKqY2msFYdnfwM3PZeZ3c7LALLhWG56/fIYMtV78+cfqkRPM8nRJXaF
+Aza2YTTZGfh3x10KnSLWUmhIWUEj8VzCNW7SR0Ecqa+ordAYio4wBsq7sO3sCw8G
+Oi0/98ondhGJWL3M6FDGai8dXewt+8o0dlq95mHkNNopCWbPI71pM7u4ABPL50Yd
+spd4eADxTm2m0GR7bhVEIbYfc0aAzIoWDpVs4V3vmx+bdRbppFxV1aS/r0g=
+-----END RSA PRIVATE KEY-----'''
+
+ header = {
+ 'alg': 'RS256',
+ 'typ': 'JWT',
+ 'kid': '0d1bb0d7-45e4-445c-889e-57419470a570'
+ }
+
+ payload = {
+ **json_data,
+ 'iat': int(datetime.now().timestamp()),
+ 'exp': int((datetime.now() + timedelta(minutes=10)).timestamp()),
+ 'iss': 'https://ora.sh'
+ }
+
+ return jwt.encode(payload, private_key, algorithm='RS256', headers=header) \ No newline at end of file