Skip to main content

A python JWT validator that does all the BYU specific stuff as well.

Project description

# byu-jwt-python
A python JWT validator that does all the BYU specific stuff as well.

You will need a file named ~/.byu/byu-jwt-python.yaml with the following contents. Get your info at https://api.byu.edu/store/site/pages/subscriptions.jag
```
client_id: <your WSO2 application's Consumer Key>
client_secret: <your WSO2 application's Consumer Secret>
```

## API

### How to Validate a JWT

```
import byu_jwt
try:
decode(jwt_to_validate)
# valide JWT
except Exception:
# invalid JWT
```

### JWT Header Names

BYU's API Manager creates an HTTP header that contains a signed [JWT](https://jwt.io/). The names of the designed BYU signed headers can be referenced here for lookup convenience.

### BYU_JWT_HEADER_CURRENT

The property containing the name of the HTTP header that contains the BYU signed JWT sent directly from BYU's API Manager.

Value is X-JWT-Assertion.

Example

```
import byu_jwt
current_jwt_header = byu_jwt.BYU_JWT_HEADER_CURRENT
```

### BYU_JWT_HEADER_ORIGINAL

The property containing the name of the HTTP header that contains the BYU signed JWT forwarded on from a service that received the BYU signed JWT sent directly from BYU's API Manager.

Value is X-JWT-Assertion-Original.

Example

```
import byu_jwt
original_jwt_header = byu_jwt.BYU_JWT_HEADER_ORIGINAL
```

## Testing
To run the integration tests do the following:

First make sure you have python and python3 installed on your system, then install virtualenv in whatever way you install python modules (usually `$ pip install virtualenv`).

```
$ virtualenv venv
$ source venv/bin/activate
$ pip install -r requirements
$ pip3 install -r requirements
$ python byu_jwt.py True
# The 'True' makes the tests run in verbose mode.
# Leaving it off will run the tests silently and they will only print info if any tests fail.
$ python3 byu_jwt.py True
$ deactivate # to get out of the virtualenv
```

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

byu_jwt-1.1.0.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file byu_jwt-1.1.0.tar.gz.

File metadata

  • Download URL: byu_jwt-1.1.0.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for byu_jwt-1.1.0.tar.gz
Algorithm Hash digest
SHA256 85bcb5196e32eaa04246a9b8acc5222236177e2951cabaea4d4eb09f67cf13d9
MD5 c7059db3d8a618fde05b42bcd5cc93df
BLAKE2b-256 d2d2200f76f0e51544d410fb870d692461ccb4606db25c342a869ef40c081872

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