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')
Metadata
Release files for atlassian-jwt-auth 3.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| atlassian-jwt-auth-3.3.0.tar.gz | 26.6 kB | Without provenance | Details for atlassian-jwt-auth-3.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| atlassian_jwt_auth-3.3.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for atlassian_jwt_auth-3.3.0-py2.py3-none-any.whl |
Total release size: 64.7 kB
Release files / atlassian-jwt-auth-3.3.0.tar.gz
| Download URL | atlassian-jwt-auth-3.3.0.tar.gz |
|---|---|
| Size | 26.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9caa3f214799e7231b36d471cc0103e730ee177ca3d5488310b8843dd1c4370b
|
|
BLAKE2b-256 checksum How to use checksums |
1dfa4283c9d8be458292b2442af89eb90cdfccb880013d4b9fc4e31f0df6cc50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / atlassian_jwt_auth-3.3.0-py2.py3-none-any.whl
| Download URL | atlassian_jwt_auth-3.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 38.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
15b14c629fdf190266fd4a2bdc05c36b79b38d0d84489c11b1da19c205de7f43
|
|
BLAKE2b-256 checksum How to use checksums |
9d1efa722530fb5c5f97c56592d05c8ef3bf79d4ceda4798ef8024e77bdf5813
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for atlassian-jwt-auth 3.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.