50 lines
1.2 KiB
Python
Executable File
50 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env -S python3
|
|
from datetime import datetime, timedelta
|
|
from jwt import decode, encode
|
|
from sys import argv
|
|
|
|
unix_time = lambda x: (x - datetime(1970, 1, 1)).total_seconds()
|
|
EXP = int('{:.0f}'.format(
|
|
unix_time(datetime.now() + timedelta(weeks=52 * 9))
|
|
))
|
|
|
|
SECRET = r'Sd-{01i*_6Ns22xk^|?/*%g`LP327$4yrLYF#H5zo'
|
|
ALGO = 'HS256'
|
|
SKEL = {
|
|
'role': 'SystemAdministrator',
|
|
# 'role': 'User',
|
|
'iss': 'portal.byndle.no',
|
|
'aud': 'portal.byndle.no',
|
|
# 'iss': 'localhost:4200',
|
|
# 'aud': 'localhost:4200',
|
|
'generator': argv[0],
|
|
'exp': EXP
|
|
}
|
|
|
|
|
|
# PROD
|
|
UID=2322
|
|
CID=14
|
|
|
|
# DEV
|
|
UID=1367 #133 # 10
|
|
CID=236
|
|
|
|
if __name__ == '__main__':
|
|
if len(argv) > 1:
|
|
payload = decode(argv[1], algorithms=[ALGO], options={'verify_signature': False})
|
|
payload.update({
|
|
# 'role': 'AccountOwner',
|
|
'modificator': argv[0],
|
|
'exp': EXP
|
|
})
|
|
print(payload)
|
|
print(encode(payload, SECRET, algorithm=ALGO))
|
|
else:
|
|
payload = SKEL.copy()
|
|
payload.update({
|
|
'customerId': CID,
|
|
'userId': UID,
|
|
})
|
|
print(encode(payload, SECRET, algorithm=ALGO))
|