lol
This commit is contained in:
@@ -13,11 +13,15 @@ from werkzeug.datastructures import CallbackDict
|
||||
from .json.tag import TaggedJSONSerializer
|
||||
|
||||
if t.TYPE_CHECKING: # pragma: no cover
|
||||
import typing_extensions as te
|
||||
|
||||
from .app import Flask
|
||||
from .wrappers import Request, Response
|
||||
from .wrappers import Request
|
||||
from .wrappers import Response
|
||||
|
||||
|
||||
class SessionMixin(MutableMapping):
|
||||
# TODO generic when Python > 3.8
|
||||
class SessionMixin(MutableMapping): # type: ignore[type-arg]
|
||||
"""Expands a basic dictionary with session attributes."""
|
||||
|
||||
@property
|
||||
@@ -45,7 +49,8 @@ class SessionMixin(MutableMapping):
|
||||
accessed = True
|
||||
|
||||
|
||||
class SecureCookieSession(CallbackDict, SessionMixin):
|
||||
# TODO generic when Python > 3.8
|
||||
class SecureCookieSession(CallbackDict, SessionMixin): # type: ignore[type-arg]
|
||||
"""Base class for sessions based on signed cookies.
|
||||
|
||||
This session backend will set the :attr:`modified` and
|
||||
@@ -68,7 +73,7 @@ class SecureCookieSession(CallbackDict, SessionMixin):
|
||||
accessed = False
|
||||
|
||||
def __init__(self, initial: t.Any = None) -> None:
|
||||
def on_update(self) -> None:
|
||||
def on_update(self: te.Self) -> None:
|
||||
self.modified = True
|
||||
self.accessed = True
|
||||
|
||||
@@ -177,7 +182,7 @@ class SessionInterface:
|
||||
|
||||
def get_cookie_name(self, app: Flask) -> str:
|
||||
"""The name of the session cookie. Uses``app.config["SESSION_COOKIE_NAME"]``."""
|
||||
return app.config["SESSION_COOKIE_NAME"]
|
||||
return app.config["SESSION_COOKIE_NAME"] # type: ignore[no-any-return]
|
||||
|
||||
def get_cookie_domain(self, app: Flask) -> str | None:
|
||||
"""The value of the ``Domain`` parameter on the session cookie. If not set,
|
||||
@@ -189,8 +194,7 @@ class SessionInterface:
|
||||
.. versionchanged:: 2.3
|
||||
Not set by default, does not fall back to ``SERVER_NAME``.
|
||||
"""
|
||||
rv = app.config["SESSION_COOKIE_DOMAIN"]
|
||||
return rv if rv else None
|
||||
return app.config["SESSION_COOKIE_DOMAIN"] # type: ignore[no-any-return]
|
||||
|
||||
def get_cookie_path(self, app: Flask) -> str:
|
||||
"""Returns the path for which the cookie should be valid. The
|
||||
@@ -198,27 +202,27 @@ class SessionInterface:
|
||||
config var if it's set, and falls back to ``APPLICATION_ROOT`` or
|
||||
uses ``/`` if it's ``None``.
|
||||
"""
|
||||
return app.config["SESSION_COOKIE_PATH"] or app.config["APPLICATION_ROOT"]
|
||||
return app.config["SESSION_COOKIE_PATH"] or app.config["APPLICATION_ROOT"] # type: ignore[no-any-return]
|
||||
|
||||
def get_cookie_httponly(self, app: Flask) -> bool:
|
||||
"""Returns True if the session cookie should be httponly. This
|
||||
currently just returns the value of the ``SESSION_COOKIE_HTTPONLY``
|
||||
config var.
|
||||
"""
|
||||
return app.config["SESSION_COOKIE_HTTPONLY"]
|
||||
return app.config["SESSION_COOKIE_HTTPONLY"] # type: ignore[no-any-return]
|
||||
|
||||
def get_cookie_secure(self, app: Flask) -> bool:
|
||||
"""Returns True if the cookie should be secure. This currently
|
||||
just returns the value of the ``SESSION_COOKIE_SECURE`` setting.
|
||||
"""
|
||||
return app.config["SESSION_COOKIE_SECURE"]
|
||||
return app.config["SESSION_COOKIE_SECURE"] # type: ignore[no-any-return]
|
||||
|
||||
def get_cookie_samesite(self, app: Flask) -> str:
|
||||
def get_cookie_samesite(self, app: Flask) -> str | None:
|
||||
"""Return ``'Strict'`` or ``'Lax'`` if the cookie should use the
|
||||
``SameSite`` attribute. This currently just returns the value of
|
||||
the :data:`SESSION_COOKIE_SAMESITE` setting.
|
||||
"""
|
||||
return app.config["SESSION_COOKIE_SAMESITE"]
|
||||
return app.config["SESSION_COOKIE_SAMESITE"] # type: ignore[no-any-return]
|
||||
|
||||
def get_expiration_time(self, app: Flask, session: SessionMixin) -> datetime | None:
|
||||
"""A helper method that returns an expiration date for the session
|
||||
|
||||
Reference in New Issue
Block a user