jamlib


Namejamlib JSON
Version 2.3.3 PyPI version JSON
download
home_pageNone
SummarySimple and univirsal library for authorization.
upload_time2025-10-06 21:38:40
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License
keywords authentication backend jwt sessions otp totp litestar fastapi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Jam

![logo](https://github.com/lyaguxafrog/jam/blob/master/docs/assets/h_logo_n_title.png?raw=true)

![Static Badge](https://img.shields.io/badge/Python-3.9%2B-blue?logo=python&logoColor=white)
[![PyPI - Version](https://img.shields.io/pypi/v/jamlib)](https://pypi.org/project/jamlib/)
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/jamlib?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=RED&left_text=Downloads)](https://pypi.org/project/jamlib/)
![tests](https://github.com/lyaguxafrog/jam/actions/workflows/run-tests.yml/badge.svg)
[![GitHub License](https://img.shields.io/github/license/lyaguxafrog/jam)](https://github.com/lyaguxafrog/jam/blob/master/LICENSE.md)

Documentation: [jam.makridenko.ru](https://jam.makridenko.ru)

## Install
```bash
pip install jamlib
```

## Getting start
```python
# -*- 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](https://authx.yezz.me/)       | ✅   |  ❌                       |  ✅                  | ❌   | ✅      | ❌     |
| [PyJWT](https://pyjwt.readthedocs.io) | ✅   | ❌                         | ❌                  | ❌   | ❌      | ❌     |
| [AuthLib](https://docs.authlib.org)   | ✅   | ❌                         | ❌                  | ❌  | ✅      | ❌     |
| [OTP Auth](https://otp.authlib.org/)  | ❌   | ❌                         | ❌                  | ✅   | ❌      | ❌     |

## Roadmap
![Roadmap](https://jam.makridenko.ru/assets/roadmap.png?raw=true)


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jamlib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "Authentication, Backend, JWT, Sessions, OTP, TOTP, Litestar, FastAPI",
    "author": null,
    "author_email": "Makridenko Adrian <adrianmakridenko@duck.com>",
    "download_url": "https://files.pythonhosted.org/packages/b4/70/03295283b48354803a5eee32fd2b3df1bec5c7ecf036a17bbc287871adb2/jamlib-2.3.3.tar.gz",
    "platform": null,
    "description": "# Jam\n\n![logo](https://github.com/lyaguxafrog/jam/blob/master/docs/assets/h_logo_n_title.png?raw=true)\n\n![Static Badge](https://img.shields.io/badge/Python-3.9%2B-blue?logo=python&logoColor=white)\n[![PyPI - Version](https://img.shields.io/pypi/v/jamlib)](https://pypi.org/project/jamlib/)\n[![PyPI Downloads](https://static.pepy.tech/personalized-badge/jamlib?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=RED&left_text=Downloads)](https://pypi.org/project/jamlib/)\n![tests](https://github.com/lyaguxafrog/jam/actions/workflows/run-tests.yml/badge.svg)\n[![GitHub License](https://img.shields.io/github/license/lyaguxafrog/jam)](https://github.com/lyaguxafrog/jam/blob/master/LICENSE.md)\n\nDocumentation: [jam.makridenko.ru](https://jam.makridenko.ru)\n\n## Install\n```bash\npip install jamlib\n```\n\n## Getting start\n```python\n# -*- coding: utf-8 -*-\n\nfrom jam import Jam\n\n# jwt\nconfig = {\n    \"auth_type\": \"jwt\",\n    \"secret_key\": \"secret\",\n    \"expire\": 3600\n}\n\njam = Jam(config=config)\ntoken = jam.gen_jwt_token({\"user_id\": 1})  # eyJhbGciOiAiSFMyN...\n\n# sessions\nconfig = {\n    \"auth_type\": \"sessions\",\n    \"session_type\": \"redis\",\n    \"redis_uri\": \"redis://0.0.0.0:6379/0\",\n    \"default_ttl\": 30 * 24 * 60 * 60,\n    \"session_path\": \"sessions\"\n}\n\njam = Jam(config=config)\nsession_id = jam.create_session(\n    session_key=\"username@somemail.com\",\n    data={\"user_id\": 1, \"role\": \"user\"}\n)  # username@somemail.com:9f46...\n# You alse can crypt your sessions, see: jam.makridenko.ru/sessions/session_crypt/\n\n# OTP\n# Since OTP is most often the second factor for authorization,\n# in Jam, the OTP setting complements the main authorization configuration\nconfig = {\n    \"auth_type\": \"jwt\", # jwt for example\n    \"alg\": \"HS256\",\n    \"secret_key\": \"SOME_SECRET\",\n    \"otp\": {\n        \"type\": \"totp\",\n        \"digits\": 6,\n        \"digest\": \"sha1\",\n        \"interval\": 30\n    }\n}\n\njam = Jam(config=config)\ncode = jam.get_otp_code(\n    secret=\"USERSECRETKEY\"\n)  # '735891'\n```\n\n## Why Jam?\nJam is a library that provides the most popular AUTH* mechanisms right out of the box.\n\n| Library                               | JWT | White/Black lists for JWT | Serverside sessions | OTP | OAuth2 | Flexible config |\n|---------------------------------------|-----|---------------------------|--------------------|-----|--------|-------|\n| **Jam**                               | \u2705   | \u2705                         | \u2705                  | \u2705   | \u23f3      | \u2705     |\n| [Authx](https://authx.yezz.me/)       | \u2705   |  \u274c                       |  \u2705                  | \u274c   | \u2705      | \u274c     |\n| [PyJWT](https://pyjwt.readthedocs.io) | \u2705   | \u274c                         | \u274c                  | \u274c   | \u274c      | \u274c     |\n| [AuthLib](https://docs.authlib.org)   | \u2705   | \u274c                         | \u274c                  | \u274c  | \u2705      | \u274c     |\n| [OTP Auth](https://otp.authlib.org/)  | \u274c   | \u274c                         | \u274c                  | \u2705   | \u274c      | \u274c     |\n\n## Roadmap\n![Roadmap](https://jam.makridenko.ru/assets/roadmap.png?raw=true)\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Simple and univirsal library for authorization.",
    "version": "2.3.3",
    "project_urls": {
        "Changelog": "https://github.com/lyaguxafrog/jam/releases",
        "Homepage": "https://jam.makridenko.ru",
        "Issues": "https://github.com/lyaguxafrog/jam/issues",
        "Repository": "https://github.com/lyaguxafrog/jam"
    },
    "split_keywords": [
        "authentication",
        " backend",
        " jwt",
        " sessions",
        " otp",
        " totp",
        " litestar",
        " fastapi"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "64da3dee5cf2ed7d694e7c1ef7c375042fdfb14e9c082e90a52d3b69b8ae1b8e",
                "md5": "e4c17d2b222b17c84ab0594582b5dc09",
                "sha256": "0a4f327cc0958f5650c2b78eb190b6d4ede58ed1af9e85beae85adad56255901"
            },
            "downloads": -1,
            "filename": "jamlib-2.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e4c17d2b222b17c84ab0594582b5dc09",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 47487,
            "upload_time": "2025-10-06T21:38:39",
            "upload_time_iso_8601": "2025-10-06T21:38:39.799544Z",
            "url": "https://files.pythonhosted.org/packages/64/da/3dee5cf2ed7d694e7c1ef7c375042fdfb14e9c082e90a52d3b69b8ae1b8e/jamlib-2.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b47003295283b48354803a5eee32fd2b3df1bec5c7ecf036a17bbc287871adb2",
                "md5": "65d2b0e6c9d7c2d85167d7124bcd3bbb",
                "sha256": "d0293d5cb30d76990283a666fc391e8ba8ddbf3d0f39349ee24446f15253c8d2"
            },
            "downloads": -1,
            "filename": "jamlib-2.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "65d2b0e6c9d7c2d85167d7124bcd3bbb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 33230,
            "upload_time": "2025-10-06T21:38:40",
            "upload_time_iso_8601": "2025-10-06T21:38:40.854955Z",
            "url": "https://files.pythonhosted.org/packages/b4/70/03295283b48354803a5eee32fd2b3df1bec5c7ecf036a17bbc287871adb2/jamlib-2.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-06 21:38:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lyaguxafrog",
    "github_project": "jam",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "jamlib"
}
        
Elapsed time: 1.25784s