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

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

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.4.0a4.tar.gz (36.8 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.4.0a4-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

Details for the file jamlib-2.4.0a4.tar.gz.

File metadata

  • Download URL: jamlib-2.4.0a4.tar.gz
  • Upload date:
  • Size: 36.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.24

File hashes

Hashes for jamlib-2.4.0a4.tar.gz
Algorithm Hash digest
SHA256 de64b88e68a71b9897d2519e815cc235873e76ebc50c82386640ad24ce8ed53a
MD5 696bf53db88ab00eaf18b161f990ea99
BLAKE2b-256 d198bed578f5c3ec692e966fb141e5ea025e2f2d508381963262bf64059260f1

See more details on using hashes here.

File details

Details for the file jamlib-2.4.0a4-py3-none-any.whl.

File metadata

  • Download URL: jamlib-2.4.0a4-py3-none-any.whl
  • Upload date:
  • Size: 53.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.24

File hashes

Hashes for jamlib-2.4.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 731658311ccd2a0b0ccea84b77f3b5339cd4b889e20efeecd9a7b40e501f7a8c
MD5 8f670d6bb61a2635f4ac41e0816bc5c3
BLAKE2b-256 687ba4ca7cb18ce501d213c4c708bed3645c077332aedb3b9c0f880f164fcf23

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