Skip to content

Repository files navigation

Jam

logo

Python Version PyPI - Version PyPI Downloads tests Ask DeepWiki GitHub License

Jam (Jam Auth Module) - Jam (Jam Auth Module) - A universal auth* framework that provides popular auth mechanisms strictly according to the specification.

Install

pip install jamlib

Quick example

from dataclasses import dataclass

from jam import BaseSubject, Jam


@dataclass
class User(BaseSubject):
    id: int
    email: str


jam = Jam(config="config.toml", subject=User)

user = User(id=1, email="user@example.com")

token = jam.issue(subject=user, via="jwt")
principal = jam.authenticate(token, via="jwt")
user = principal.subject

allowed: bool = jam.authorize(
    principal=principal,
    permission="post:create"
)

Why Jam?

Jam is a library that provides the most popular AUTH* mechanisms right out of the box.

Authorization

Jam combines permissions granted to one credential with server-side policy rules. This makes it possible to issue two tokens for the same user with different permissions and to restrict those permissions using the current time, resource or request.

principal = jam.authenticate(token, via="jwt")

if jam.authorize(principal, "user:delete"):
    ...

Framework integrations

Jam provides ready-to-use integrations for the most popular frameworks:

Each integration offers built-in middleware or plugin support for JWT and session-based authentication.

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
JOSE ❌ only JWT ❌ only JWT
JWT black/white lists
PASETO
Server side sessions
OTP
OAuth2
SAML 2.0
Flexible config
Modularity

About

Jam (Jam Auth Module) - A universal auth* framework that provides popular auth mechanisms strictly according to the specification.

Topics

Resources

Security policy

Stars

22 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages