forked from eclipse-archived/kuksa.val
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateToken.py
executable file
·39 lines (24 loc) · 985 Bytes
/
createToken.py
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
#!/usr/bin/env python
# All rights reserved. This configuration file is provided to you under the
# terms and conditions of the Eclipse Distribution License v1.0 which
# accompanies this distribution, and is available at
# http://www.eclipse.org/org/documents/edl-v10.php
import json
import jwt
import argparse
def createJWTToken(input, key):
print("Reading JWT payload from {}".format(input))
with open(input,'r') as file:
payload=json.load(file)
encoded=jwt.encode(payload,key,algorithm='RS256')
print("Writing signed key to {}".format(input+".token"))
with open(input+".token",'w') as output:
output.write(encoded)
parser = argparse.ArgumentParser()
parser.add_argument("files", help="Read JWT payload from these files", nargs='+')
args = parser.parse_args()
print("Reading private key from {}".format('jwt.key'))
with open('jwt.key','r') as file:
key=file.read()
for input in args.files:
createJWTToken(input,key)