Skip to main content

jwkaas

Python JSON Web Key Advanced Acquiring Store

Introduction to JWT, JWS and JWK

This Python module provides JSON Web Token decoding and verification. The validity of a JWT is based on theJSON Web Signature (JWS). A signature is verified using the corresponding JSON Web Key (JWK). Many identify providers publish the JSON Web Keys to verify their signatures as a JSON document on the Internet (these are referred to as the JWKS). A JWT may contain several claims (see RFC 7519). jwkaas will check the exp and nbf claim based on the current time. The aud and iss claim will be verified based on whether this information was specified on initialization (see Usage below)

Introduction to jwkaas

The Python module jwkaas provides the functionality to verify a JWT and decode it to get the information from the JWT. It includes acquiring and storing the JWKS required to verify the signatures.

Usage

The functionality is provided by the JWKaas class. On initialization the expected audience and issuer must specified. A JWT will only be accepted if the values match the corresponding token claims aud and iss. The JWKS can be specified by an url from where the JWKS json can be downloaded, and/or by a file containing the JWKS json. If both sources contain a key with the same key id (kid), the key from the url will precede the key from the file. Example initialisation:

my_jwkaas = JWKaas('https://my.audience'", 
                   'https://my.iam.server/issueing/the/token',
                   jwks_url='https://my.iam.server/well-known/keys.jwks')

Verifying and decoding a JWT is done by the JWKaas.get_token_info, like this:

token_info = my_jwkaas.get_token_info(token)
if token_info is not None:
    logging.info("Token info: %s", token_info)
else:
    logging.info("Token is invalid")

Using jwkaas with Connexion OpenAPI First framework for Python

JWKaas also provides JWKaas.get_connexion_token_info. This returns the token_info extended with the scope key as used by Connexion. The value of scope will be copied from the scp claim, which is the claim used by Azure AD to specify the scopes. Other IAM servers might use yet another claim to specify the scopes, those are currently not implemented.

Acknowledgements

jwkaas is build around PyJWT, a Python implementation of RFC 7519.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jwkaas-0.5.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jwkaas-0.5-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file jwkaas-0.5.tar.gz.

File metadata

  • Download URL: jwkaas-0.5.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9

File hashes

Hashes for jwkaas-0.5.tar.gz
Algorithm Hash digest
SHA256 3b663b4c961e257d19811458df1d5ef158d2bf5b4822f0b1bf77349287e35ff6
MD5 39db3db19f158c8a50e87d484d62c341
BLAKE2b-256 ffcc066f5adf03a12defa8673bed42b4d65d70f9a02f11e5caa5b3a6b6f76a9e

See more details on using hashes here.

File details

Details for the file jwkaas-0.5-py3-none-any.whl.

File metadata

  • Download URL: jwkaas-0.5-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9

File hashes

Hashes for jwkaas-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d93feb60d652e6df30a8fbea020fa5381d1826e924a114c61114e7ee4625cae5
MD5 5e68213e9eb87e6d4a02bd3f847e62f9
BLAKE2b-256 4ef5a1bfbf67a88717723c75d9750d78b380045f1de1266bee0c9d7e7c79b660

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page