Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Python implementation of the Atlassian Service to Service Authentication specification.

Project Description

This package provides an implementation of the Service to Service Authentication specification.


Installation

To install simply run

$ pip install atlassian-jwt-auth

Using this library

To create a JWT for authentication

import atlassian_jwt_auth


signer = atlassian_jwt_auth.create_signer('issuer', 'issuer/key', private_key_pem)
a_jwt = signer.generate_jwt('audience')

To create a JWT using a file on disk in the conventional location

Each time you call generate_jwt this will find the latest active key file (ends with .pem) and use it to generate your JWT.

import atlassian_jwt_auth


signer = atlassian_jwt_auth.create_signer_from_file_private_key_repository('issuer', '/opt/jwtprivatekeys')
a_jwt = signer.generate_jwt('audience')

To make an authenticated HTTP request

If you use the atlassian_jwt_auth.contrib.requests.JWTAuth provider, you can automatically generate JWT tokens when using the requests library to perform authenticated HTTP requests.

import atlassian_jwt_auth
from atlassian_jwt_auth.contrib.requests import JWTAuth

signer = atlassian_jwt_auth.create_signer('issuer', 'issuer/key', private_key_pem)
response = requests.get(
    'https://your-url',
    auth=JWTAuth(signer, 'audience')
)

One can also use atlassian_jwt_auth.contrib.aiohttp.JWTAuth to authenticate aiohttp requests:

import aiohttp

import atlassian_jwt_auth
from atlassian_jwt_auth.contrib.aiohttp import JWTAuth

signer = atlassian_jwt_auth.create_signer('issuer', 'issuer/key', private_key_pem)

async with aiohttp.ClientSession() as session:
    async with session.get('https://your-url',
                           auth=JWTAuth(signer, 'audience')) as resp:
        ...

To verify a JWT

import atlassian_jwt_auth

public_key_retriever = atlassian_jwt_auth.HTTPSPublicKeyRetriever('https://example.com')
verifier = atlassian_jwt_auth.JWTAuthVerifier(public_key_retriever)
verified_claims = verifier.verify_jwt(a_jwt, 'audience')

For Python versions starting from Python 3.5 atlassian_jwt_auth.contrib.aiohttp provides drop-in replacements for the components that perform HTTP requests, so that they use aiohttp instead of requests:

import atlassian_jwt_auth.contrib.aiohttp

public_key_retriever = atlassian_jwt_auth.contrib.aiohttp.HTTPSPublicKeyRetriever('https://example.com')
verifier = atlassian_jwt_auth.contrib.aiohttp.JWTAuthVerifier(public_key_retriever)
verified_claims = await verifier.verify_jwt(a_jwt, 'audience')
Release History

Release History

This version
History Node

3.3.0

History Node

3.2.2

History Node

3.2.2.dev1

History Node

3.2.1

History Node

3.1.0

History Node

3.0.1

History Node

3.0.0

History Node

2.11.2

History Node

2.11.1

History Node

2.11.0

History Node

2.10.2

History Node

2.10.1

History Node

2.10.0

History Node

2.9.0

History Node

2.8.1

History Node

2.8.0

History Node

2.7.0

History Node

2.6.0

History Node

2.5.2

History Node

2.5.1

History Node

2.5.0

History Node

2.4.0

History Node

2.3.0

History Node

2.2.0

History Node

2.1.2.dev4

History Node

2.1.1

History Node

2.1.1.dev5

History Node

2.1.0

History Node

2.0.1.dev4

History Node

2.0.1.dev3

History Node

2.0.0

History Node

2.0.0.dev18

History Node

2.0.0.dev17

History Node

2.0.0.dev11

History Node

1.0.9

History Node

1.0.9.dev4

History Node

1.0.9.dev3

History Node

1.0.9.dev2

History Node

1.0.9.dev1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
atlassian_jwt_auth-3.3.0-py2.py3-none-any.whl (38.1 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Nov 29, 2017
atlassian-jwt-auth-3.3.0.tar.gz (26.6 kB) Copy SHA256 Checksum SHA256 Source Nov 29, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting