How to use the jwcrypto.jwk.JWK.from_uri function in jwcrypto

To help you get started, we’ve selected a few jwcrypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / trusted-service-identity / components / vtpm-server / validate-jwt.py View on Github external
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)
github IBM / trusted-service-identity / components / vtpm-server / gen-jwt.py View on Github external
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())