Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main(args):
if os.path.isfile(args.key):
with open(args.key) as f:
pem_data = f.read()
f.closed
key = jwk.JWK.from_pem(pem_data)
else:
key = jwk.JWK.from_uri(args.key)
with open(args.jwt) as f:
raw_jwt = f.read()
f.closed
token = jwt.JWT()
token.deserialize(raw_jwt, key)
def main(args):
"""Generates a signed JSON Web Token from local private key."""
# Begin modification
if os.path.isfile(args.key):
with open(args.key) as f:
pem_data = f.read()
f.closed
key = jwk.JWK.from_pem(pem_data)
else:
key = jwk.JWK.from_uri(args.key)
# End modification
if args.jwks:
with open(args.jwks, "w+") as fout:
# this is the old JWKS format
# fout.write("{ \"keys\":[ ")
# fout.write(key.export(private_key=False))
# fout.write("]}")
# this is the new PEM format
fout.write("{ \"jwt_validation_pubkeys\": \"")
fout.write(key.public().export_to_pem())
fout.write("\" }")
fout.close
now = int(time.time())