Yet Another JWT wrapper for Python
Project description
yajwt
yajwt is Yet Another JWT wrapper for Python.
Public/private keys
yajwt supports public/private keys management. To accomplish that, one should create a .JSON file with the following schema:
{
"team": "testing-user",
"key": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5T8bGxmc/Wk4p2kC2IOU\nzpLHSQ28bkpP26x9PiQDQsPZMf1bBgZM213bGi0j34jcx6gp/rAFoLmhaFY3PThr\nVgZKBE3elvCxZwAoTrkR+Vpwe6cWF3dEiakiWkiu8blRuZjFEqQJyQLy/ycTA+x7\nRDc1oqKUl7dvsN/AKHTRNmCW7X1fuEHrvqi/4RXBUzmC2HVD3+pXBQH0uJeOqLtQ\nQMf9mZtBM10LwKa9ise/k+Uv0I5X3IUshHGG2WbWEwtvlHCHV/3pF4DuEONqySqN\ni9iAyN1JABtQVt8y5jcDkQv7oeQa9Rwb9wxufAjKcQA4o4Syhe8dAnWHZ/c++zPJ\n5QIDAQAB\n-----END PUBLIC KEY-----\n",
"payload": {
"iss": "testing-user",
"version": "1"
},
"algorithm": "RS256",
"key_type": "public"
}
team
is used to identify .JSON file.
payload
can be changed according to your specifications, however iss
is needed to
verify incoming tokens.
algorithm
can also be changed according to your specifications.
key_type
can be public
or private
.
Examples
How to make a request?
keys_path = os.path.join(os.getcwd(), "examples", "keys")
jwt_keys_manager = JwtKeysDirectoryManager(keys_path)
jwt_requests = JwtRequestsWrapper(jwt_keys_manager, JwtResponseMapper(), TOKEN_TTL)
response = jwt_requests.get("https://example.com", "testing-user")
if response.status == HTTPStatus.OK:
print(response)
How to validate a request?
keys_path = os.path.join(os.getcwd(), "examples", "keys")
jwt_keys_manager = JwtKeysDirectoryManager(keys_path)
jwt_validator = JwtRequestsValidator(jwt_keys_manager)
token = (
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJ0ZXN0aW5nLXVzZXIiLCJ2"
"ZXJzaW9uIjoiMSIsImV4cCI6MTYwNzU5NDU5OX0.s_fuw0ut1bOOLwKgbPWDtubqO7X6c"
"te52jtSalHrzoiMYWeWflHXbCFel9VVeLFt6oDN_Yf2xgMx3bx71W3yUQ21jjqwSCYVR5"
"B6dw-mM15U7v-KJKbjVpBU_KOkkNyqINJAJaB6imB6zz2UG4Du68NKzlPHbCHt4VGVNIQ"
"-4cz5kbLMkXoZmX0sO3kTqSXpW4KkB9_8IxPNGYwdaqgsVn22Hlkf9-ER8QDsn-e69Bwx"
"fGnqf-i5J0s3uWmSvboCciE6TIYkiutH8S93rooHLJb96mglmqLu2rcH3fqr9u1hg28jG"
"er5LRZCK1N2HsnqSGnjc1MOhnKgX5OlrHIbAg"
)
jwt_token = jwt_validator.validate(token)
if jwt_token.valid:
print(jwt_token.payload)
print(jwt_token)
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
yajwt-0.1.0.tar.gz
(7.7 kB
view details)
Built Distribution
yajwt-0.1.0-py3-none-any.whl
(25.4 kB
view details)
File details
Details for the file yajwt-0.1.0.tar.gz
.
File metadata
- Download URL: yajwt-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 414747fb65bde1101b228e843d9c0f92640ecec5b35679d4d9c8ab85e7abd5be |
|
MD5 | d2a46d70f9f9f6c31a579e3724591e55 |
|
BLAKE2b-256 | 7b0147f95f60aa478ad2da82c8cf87632f783b454f1484c607604ffadc8dd395 |
File details
Details for the file yajwt-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: yajwt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d39ab3fb7489ee1fd1a302f595b7ee07af4ed2acfda5acccb898d56397d02e7a |
|
MD5 | 319a53509ee02574361d0a271ee0620e |
|
BLAKE2b-256 | 677bae357537e912ecf67c991ba8a9d6333101b897425dc5d817f19583e275db |