Skip to main content

GCP-JWT

GCP-JWT is a library to create and sign tokens using the Google Cloud Platform's Key Management Service. It handles the signing and verification of the token.

Key Features

  • Token Signage
  • Signature Verification
  • Expiry Verification

  • Auto Rotating Asymmetric Key
  • Batch Token Generation
  • Compression Option
  • Symmetrically Encrypted Layer
  • Pretty API

GCP Roles Needed

To be able to use this library you'll need a GCP service account with at least the following roles:

  • cloudkms.cryptoKeyVersions.list
  • cloudkms.cryptoKeyVersions.useToSign
  • cloudkms.cryptoKeyVersions.viewPublicKey

Why not using GCP integrated auth ?

Some projects require more flexibility, I've also personally came across a case where a company didn't want Google to manage the authentication process. Whether or not this should be used in production is outside the scope of this project.

Simple Usage

from google.cloud import kms

from gcpjwt.jwt import JWT
from gcpjwt.jwt_signer import JWTSigner

# Create a client using a json file and initialise an asymmetric signer.
client = kms.KeyManagementServiceClient.from_service_account_file('../resources/google.json')
signer = JWTSigner(client, 'your-project', 'your-ring-location')

# Create a simple JWT without changing any claims.
jwt = JWT(signer, 'your-ring', 'your-key')
text_token = jwt.token()

Install

pip install gcp-jwt

Note: This project uses the cryptography package which needs to install natives. It might not be compatible with App Engine Standard because of the limited libraries allowed.

Metadata

Release files for gcp-jwt 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gcp-jwt 0.1.9
File Size Uploaded
gcp-jwt-0.1.9.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gcp-jwt 0.1.9
File Interpreter ABI Platform
gcp_jwt-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / gcp-jwt-0.1.9.tar.gz

Download URL gcp-jwt-0.1.9.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c5b08d5d188c90b5a4b4a55011c2e9d6e3399eaca9ea731b21747145d6456a4f
BLAKE2b-256 checksum
How to use checksums
62779a3cb74a0083611cc9a17fc83305ebd4bd2f7fa225c197c87167f17eca58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8

Release files / gcp_jwt-0.1.9-py3-none-any.whl

Download URL gcp_jwt-0.1.9-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d06fd2e55219dedd07c5ff5757a0d8bea77f2c13a56488714901d8131b3506b
BLAKE2b-256 checksum
How to use checksums
4ded39ac09a16e638f13d53488791692dcad010ac34eb23037dcfc3e671056cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page