Skip to content

Commit

Permalink
Deprecate use signer
Browse files Browse the repository at this point in the history
  • Loading branch information
Lxstr committed Feb 15, 2024
1 parent fe4a69b commit a5dba70
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/flask_session/sessions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import secrets
import time
import warnings
from abc import ABC

try:
Expand Down Expand Up @@ -69,6 +70,7 @@ class SqlAlchemySession(ServerSideSession):

class SessionInterface(FlaskSessionInterface):
def _generate_sid(self, session_id_length: int) -> str:
print(session_id_length)
return secrets.token_urlsafe(session_id_length)

def __get_signer(self, app: Flask) -> Signer:
Expand Down Expand Up @@ -110,6 +112,13 @@ def __init__(
self.app = app
self.key_prefix = key_prefix
self.use_signer = use_signer
if use_signer:
warnings.warn(
"The 'use_signer' option is deprecated and will be removed in the next minor release. "
"Please update your configuration accordingly or open an issue.",
DeprecationWarning,
stacklevel=1,
)
self.permanent = permanent
self.sid_length = sid_length
self.has_same_site_capability = hasattr(self, "get_cookie_samesite")
Expand Down Expand Up @@ -158,9 +167,9 @@ def save_session(
domain=self.get_cookie_domain(app),
path=self.get_cookie_path(app),
secure=self.get_cookie_secure(app),
samesite=self.get_cookie_samesite(app)
if self.has_same_site_capability
else None,
samesite=(
self.get_cookie_samesite(app) if self.has_same_site_capability else None
),
)
response.vary.add("Cookie")

Expand All @@ -172,7 +181,6 @@ def open_session(self, app: Flask, request: Request) -> ServerSideSession:
if not sid:
sid = self._generate_sid(self.sid_length)
return self.session_class(sid=sid, permanent=self.permanent)

# If the session ID is signed, unsign it
if self.use_signer:
try:
Expand Down

0 comments on commit a5dba70

Please sign in to comment.