Simple and univirsal library for authorization.
Project description
Jam
Documentation: jam.makridenko.ru
Install
pip install jamlib
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.
| Library | JWT | White/Black lists for JWT | Serverside sessions | OTP | OAuth2 | Flexible config |
|---|---|---|---|---|---|---|
| Jam | ✅ | ✅ | ✅ | ✅ | ⏳ | ✅ |
| Authx | ✅ | ❌ | ✅ | ❌ | ✅ | ❌ |
| PyJWT | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| AuthLib | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ |
| OTP Auth | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
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
jamlib-2.1.4.tar.gz
(25.8 kB
view details)
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
jamlib-2.1.4-py3-none-any.whl
(37.3 kB
view details)
File details
Details for the file jamlib-2.1.4.tar.gz.
File metadata
- Download URL: jamlib-2.1.4.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a127e8c8e3543d1ebfab492fec9c389ec0cf02cd0f0820709661936955d1deb3
|
|
| MD5 |
ea7594ed0fef7d4dba423cf8f77e9117
|
|
| BLAKE2b-256 |
b3d0e617f8283d71e27c698902f86a0e00364efcba14be3df599eff1fb3b431f
|
File details
Details for the file jamlib-2.1.4-py3-none-any.whl.
File metadata
- Download URL: jamlib-2.1.4-py3-none-any.whl
- Upload date:
- Size: 37.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
372e9e9448860faa554a14d71b954d4e92098dece46595e7b9da2ba1cc93e108
|
|
| MD5 |
b91a75f288c13f9b32fd4524c44aba3f
|
|
| BLAKE2b-256 |
de9f48f742f59e670140743b6235ee16a9bab065334d8c7ec26678880057593f
|