Skip to content

Breaking changes 2.5.6 to 3.0.0

Delete deprecated methods

Config

The old configuration type is no longer relevant. This helps to implement several types of authorization in a single instance, for example, JWT + OAuth2.

Old version:

[jam]
auth_type = "jwt"
secret_key = "SECRET"
In this version of the config, to implement another type of authorization, it was necessary to create another instance:
[another_jam]
auth_type = "sessions"
session_type = "redis"
redis_uri = "redis://0.0.0.0:6379"
And:
from jam import Jam

jwt_jam = Jam(config="config.toml")
sessions_jam = Jam(config="config.toml", pointer="another_jam")

New version:

[jam.jwt]
alg = "HS256"
secret_key = "SECRET"

[jam.sessions]
session_type = "redis"
redis_uri = "redis://0.0.0.0:6379"
And:
from jam import Jam

jam = Jam(config="config.toml")

#  Now we can use both authorization options in one instance.
jwt_token = jam.jwt_create_token({"user": 1})
session_id = jam.session_create("user", {"user": 1})

Instance methods

It was decided to bring all methods to a single naming format: <auth_type>_<action>. As a result, the following methods were renamed:

  • gen_jwt_token -> jwt_create
  • make_payload -> jwt_make_payload
  • verify_jwt_token -> jwt_decode
  • clear_sessions -> session_clear
  • get_session -> session_get
  • create_session -> session_create
  • delete_session -> session_delete
  • update_session -> session_update
  • rework_session -> session_rework
  • get_otp_code -> otp_code
  • get_otp_uri -> otp_uri
  • verify_otp_code -> otp_verify_code

Quick methods

Removed jam.quick as unnecessary.

Module System Refactoring

Unified Module Initialization

All modules now use factory functions (create_instance) instead of wrapper classes for consistency and better performance.

What changed: - jam.modules.SessionModule → Removed, use jam.sessions.create_instance - jam.modules.OAuth2Module → Removed, use jam.oauth2.create_instance - jam.sessions.utils.init_session_instance → Removed, use jam.sessions.create_instance - jam.paseto.utils.init_paseto_instance → Removed, use jam.paseto.create_instance - jam.otp.utils.init_otp_instance → Removed, use jam.otp.create_instance

Impact on users:

For most users: NO CHANGES NEEDED

The public API (jam.jwt_*(), jam.session_*(), jam.oauth2_*(), etc.) remains unchanged.

For users directly importing wrapper classes:

Before:

from jam.modules import SessionModule, OAuth2Module

# This will no longer work
session = SessionModule(sessions_type="redis", redis_uri="redis://localhost")
oauth2 = OAuth2Module(config={"providers": {...}})

After:

from jam.sessions import create_instance as create_session
from jam.oauth2 import create_instance as create_oauth2

# Use factory functions instead
session = create_session(session_type="redis", redis_uri="redis://localhost")
oauth2 = create_oauth2(providers={...})

For users accessing internal structure:

self.oauth2 internal structure changed:

Before:

jam = Jam(config="config.yml")
# self.oauth2 was OAuth2Module object with methods
jam.oauth2.get_authorization_url("github", ["read:user"])

After:

jam = Jam(config="config.yml")
# self.oauth2 is now a dict: {provider_name: client_instance}
jam.oauth2["github"].get_authorization_url(["read:user"])

# Public API methods still work the same:
jam.oauth2_get_authorized_url("github", ["read:user"])  # ← USE THIS

Redis sessions

Rename parameter default_ttl to ttl.

Framework integration

A complete overhaul of framework integrations; see the documentation.