Skip to content

lyaguxafrog/jam

Repository files navigation

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="[email protected]",
    data={"user_id": 1, "role": "user"}
)  # [email protected]: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

About

Simple and univirsal library for authorization.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •