Simple and univirsal library for authorization.
Project description
Jam
Documentation: jam.makridenko.ru
Install
pip install jamlib
How to install dev version: -> Jam Unstable
Getting start
# -*- coding: utf-8 -*-
from jam import Jam
# jwt
config = {
"auth_type": "jwt",
"secret_key": "secret",
"expire": 3600
}
jam = Jam(config=config)
token = jam.gen_jwt_token({"user_id": 1}) # eyJhbGciOiAiSFMyN...
# sessions
config = {
"auth_type": "sessions",
"session_type": "redis",
"redis_uri": "redis://0.0.0.0:6379/0",
"default_ttl": 30 * 24 * 60 * 60,
"session_path": "sessions"
}
jam = Jam(config=config)
session_id = jam.create_session(
session_key="username@somemail.com",
data={"user_id": 1, "role": "user"}
) # username@somemail.com:9f46...
# You alse can crypt your sessions, see: jam.makridenko.ru/sessions/session_crypt/
# OTP
# Since OTP is most often the second factor for authorization,
# in Jam, the OTP setting complements the main authorization configuration
config = {
"auth_type": "jwt", # jwt for example
"alg": "HS256",
"secret_key": "SOME_SECRET",
"otp": {
"type": "totp",
"digits": 6,
"digest": "sha1",
"interval": 30
}
}
jam = Jam(config=config)
code = jam.get_otp_code(
secret="USERSECRETKEY"
) # '735891'
Why Jam?
Jam is a library that provides the most popular AUTH* mechanisms right out of the box.
Why choose Jam? Jam supports many authentication methods out of the box with minimal dependencies. Here is a comparison with other libraries:
| Features / Library | Jam | Authx | PyJWT | AuthLib | OTP Auth |
|---|---|---|---|---|---|
| JWT | ✅ | ✅ | ✅ | ✅ | ❌ |
| JWT black/white lists | ✅ | ❌ | ❌ | ❌ | ❌ |
| Server side sessions | ✅ | ✅ | ❌ | ❌ | ❌ |
| OTP | ✅ | ❌ | ❌ | ❌ | ✅ |
| OAuth2 | ⏳ | ✅ | ❌ | ✅ | ❌ |
| Flexible config | ✅ | ❌ | ❌ | ❌ | ❌ |
| Modularity | ✅ | ❌ | ❌ | ❌ | ❌ |
Roadmap
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jamlib-2.4.0b0.tar.gz.
File metadata
- Download URL: jamlib-2.4.0b0.tar.gz
- Upload date:
- Size: 41.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86d816ded5a62092710548a74fedf7d25b8710a382532d86bbbd455516b25ee1
|
|
| MD5 |
4d2e7b2f21d693b0d951e2ca7e8dbbe0
|
|
| BLAKE2b-256 |
ca183f827595a0e1203a7d222db7fac779e5c57fe7879fb65b2deeeab7c7c595
|
File details
Details for the file jamlib-2.4.0b0-py3-none-any.whl.
File metadata
- Download URL: jamlib-2.4.0b0-py3-none-any.whl
- Upload date:
- Size: 60.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc328c1fa4987085aff55a08be67927ad8033c5a965cb1e90b5559f34cf9e1d9
|
|
| MD5 |
01aea4aaf6ac371c7acabcd387cf0b5d
|
|
| BLAKE2b-256 |
182d54db3b58fcc736f1733ba823f5361fdd8bfee35971ecaa9fcde2400afc8c
|