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"
[another_jam]
auth_type = "sessions"
session_type = "redis"
redis_uri = "redis://0.0.0.0:6379"
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"
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_createmake_payload->jwt_make_payloadverify_jwt_token->jwt_decodeclear_sessions->session_clearget_session->session_getcreate_session->session_createdelete_session->session_deleteupdate_session->session_updaterework_session->session_reworkget_otp_code->otp_codeget_otp_uri->otp_uriverify_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.