diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2025-01-16 19:09:30 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-01-16 19:38:51 +0300 |
commit | 7a23ad1fa2a5561a3575177d7240d8a1aa499718 (patch) | |
tree | b4932bad31f595149e7a42e88cf729919995d735 /contrib/python/Flask/py3/flask/sessions.py | |
parent | fbb15f5ab8a61fc7c50500e2757af0b47174d825 (diff) | |
download | ydb-7a23ad1fa2a5561a3575177d7240d8a1aa499718.tar.gz |
Intermediate changes
commit_hash:ae9e37c897fc6d514389f7089184df33bf781005
Diffstat (limited to 'contrib/python/Flask/py3/flask/sessions.py')
-rw-r--r-- | contrib/python/Flask/py3/flask/sessions.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/contrib/python/Flask/py3/flask/sessions.py b/contrib/python/Flask/py3/flask/sessions.py index 4e19270e0dc..201593f2b43 100644 --- a/contrib/python/Flask/py3/flask/sessions.py +++ b/contrib/python/Flask/py3/flask/sessions.py @@ -3,6 +3,7 @@ import typing as t import warnings from collections.abc import MutableMapping from datetime import datetime +from datetime import timezone from itsdangerous import BadSignature from itsdangerous import URLSafeTimedSerializer @@ -11,7 +12,7 @@ from werkzeug.datastructures import CallbackDict from .helpers import is_ip from .json.tag import TaggedJSONSerializer -if t.TYPE_CHECKING: +if t.TYPE_CHECKING: # pragma: no cover import typing_extensions as te from .app import Flask from .wrappers import Request, Response @@ -176,11 +177,8 @@ class SessionInterface: return isinstance(obj, self.null_session_class) def get_cookie_name(self, app: "Flask") -> str: - """Returns the name of the session cookie. - - Uses ``app.session_cookie_name`` which is set to ``SESSION_COOKIE_NAME`` - """ - return app.session_cookie_name + """The name of the session cookie. Uses``app.config["SESSION_COOKIE_NAME"]``.""" + return app.config["SESSION_COOKIE_NAME"] def get_cookie_domain(self, app: "Flask") -> t.Optional[str]: """Returns the domain that should be set for the session cookie. @@ -277,7 +275,7 @@ class SessionInterface: lifetime configured on the application. """ if session.permanent: - return datetime.utcnow() + app.permanent_session_lifetime + return datetime.now(timezone.utc) + app.permanent_session_lifetime return None def should_set_cookie(self, app: "Flask", session: SessionMixin) -> bool: @@ -385,6 +383,10 @@ class SecureCookieSessionInterface(SessionInterface): samesite = self.get_cookie_samesite(app) httponly = self.get_cookie_httponly(app) + # Add a "Vary: Cookie" header if the session was accessed at all. + if session.accessed: + response.vary.add("Cookie") + # If the session is modified to be empty, remove the cookie. # If the session is empty, return without setting the cookie. if not session: @@ -397,13 +399,10 @@ class SecureCookieSessionInterface(SessionInterface): samesite=samesite, httponly=httponly, ) + response.vary.add("Cookie") return - # Add a "Vary: Cookie" header if the session was accessed at all. - if session.accessed: - response.vary.add("Cookie") - if not self.should_set_cookie(app, session): return @@ -419,3 +418,4 @@ class SecureCookieSessionInterface(SessionInterface): secure=secure, samesite=samesite, ) + response.vary.add("Cookie") |