Python utility functions and Django/Flask middlewares for validating JWT tokens from Google's Identity-Aware Proxy
Project description
# NYT PyIAP
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.
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
Release history Release notifications | RSS feed
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.0.3.tar.gz
(3.8 kB
view details)
File details
Details for the file nyt-pyiap-0.0.3.tar.gz
.
File metadata
- Download URL: nyt-pyiap-0.0.3.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32067c784f4ef415e00b7435ba9613b0c47f40b50ac4422a3d5634b38b141bea |
|
MD5 | 552084e62f1393a6fade238d12a449b7 |
|
BLAKE2b-256 | 2503a67f574f786071ff63443436c5f5599faa4b04ac0bca13a2dfa30b0b6cc1 |