From 7d037ab1a4d188b34e140e23f125f32ee044b216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 14 Jul 2020 17:43:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20potential=20race=20conditi?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Static assets where being sent with session cookies. That doesn't make sense and might actually cause issues if an asset takes *just* long enough to load to be overtaken by a login request from something like the loginui. Found with the E2E tests, which turned out to be less flaky themselves than thought 🥳 --- src/octoprint/server/util/flask.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index 29accdc1f..c7cc8e5fb 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -10,6 +10,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms import tornado.web import flask import flask.json +import flask.sessions import flask_login import octoprint.vendor.flask_principal as flask_principal import flask_assets @@ -531,6 +532,9 @@ class OctoPrintFlaskResponse(flask.Response): class OctoPrintSessionInterface(flask.sessions.SecureCookieSessionInterface): + def should_set_cookie(self, app, session): + return flask.request.endpoint != "static" + def save_session(self, app, session, response): if flask.g.get("login_via_apikey", False): return