Skip to main content

Python utility functions and Django/Flask middlewares for validating JWT tokens from Google's Identity-Aware Proxy

Project description

Validating JWT tokens from the Google Identity-Aware Proxy as middleware.

Install

pip install -e git+git@github.com:newsdev/nyt-pyiap.git

Usage

Django

Add to settings

Update your settings.py file to add the Django middleware.

MIDDLEWARE_CLASSES = [
  ...
  'pyiap.django.VerifyJWTMiddleware',
  ...
]

The request object in views.py will have two new attributes added: - request.jwt_user_id: The Google internal ID of the user who has been verified by IAP. - request.jwt_user_email: The email address and email type of the user who has been verified by IAP.

Flask

Update your Flask app.py to wrap your instantiated Flask() application’s wsgi_app with the VerifyJWTMiddleware.

app = Flask(__name__)
app.wsgi_app = VerifyJWTMiddleware(app.wsgi_app)

The request.environ object in app.py will have two new attributes added: - request.environ['jwt_user_id']: The Google internal ID of the user who has been verified by IAP. - request.environ['jwt_user_email']: The email address and email type of the user who has been verified by IAP.

Contributing

TBD.

Project details


Download files

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

Source Distribution

nyt-pyiap-0.1.3.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file nyt-pyiap-0.1.3.tar.gz.

File metadata

  • Download URL: nyt-pyiap-0.1.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nyt-pyiap-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6fe3424075c5e6b5607253c94a43ab0943ce00a50110ba0db0b156a310a649d0
MD5 e04e572692dbb8e885d0230d99fa6c59
BLAKE2b-256 59473cabc716aeb9deecb633b0c3e2b8e75e388f1523dd131aee7493310904b6

See more details on using hashes here.

Provenance

Supported by

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