Skip to main content

Simple and univirsal library for authorization.

Project description

Jam

logo

Static Badge PyPI - Version PyPI Downloads tests GitHub License

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

Roadmap

Project details


Release history Release notifications | RSS feed

This version

2.1.2

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.2.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jamlib-2.1.2-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file jamlib-2.1.2.tar.gz.

File metadata

  • Download URL: jamlib-2.1.2.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.15

File hashes

Hashes for jamlib-2.1.2.tar.gz
Algorithm Hash digest
SHA256 3e3e479307630277590d40732318a34340fbdad5c09dda73c33fa05374637325
MD5 4ec5f04b376d9aa1d8a6a58181b7ac5f
BLAKE2b-256 e5c964bbb2b7d08b4490dec29146a5b74f9fe190cec25ba295caac2ad64c2ab1

See more details on using hashes here.

File details

Details for the file jamlib-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: jamlib-2.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.15

File hashes

Hashes for jamlib-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 afe95331932f4c49107bf30060ad7d5ba261fd16e703efd0ff29e680a3464496
MD5 9d2d8c4ff717b2a2b1f3adf1179f2d92
BLAKE2b-256 b9f1b240a4a260d5104d0af6489b912ada44c136776753de215a8d3df1317e82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page