Compare commits

...
13 Commits
Author SHA1 Message Date
Gina Häußge e603b98d0d 🔖 Preparing release of 1.4.0rc2 2019-12-02 14:11:43 +01:00
Gina Häußge e235fc299f 🐛 Make sure data is set
Closes #3364
2019-12-02 14:07:41 +01:00
Gina Häußge 4f25ed546e 🐛 Only proceed if children is set AND truthy
Closes #3363
2019-12-02 13:55:04 +01:00
Gina Häußge f72b9db6a9 🐛 Fix wrong escape
Closes #3362
2019-12-02 12:24:48 +01:00
Gina Häußge 80e8e33283 🐛 Don't logout always-logged-in AdminUser
If ACL is disabled it doesn't make sense to log it out and it's causing
issues further down the line due to different handling.

Fixes #3361
2019-12-02 12:24:44 +01:00
Gina Häußge 00d0396417 🐛 Fix autologin
Closes #3357
2019-11-29 12:50:16 +01:00
Gina Häußge 59e39662f1 🐛 timelapse: fix accessed event payload field
Closes #3354
2019-11-28 18:02:34 +01:00
Gina Häußge 038e1b9a57 🐛 appkeys: Fix a deprecation warning 2019-11-26 18:42:36 +01:00
Gina Häußge bbefeeeb02 🐛 appkeys: generate string api keys
Instead of binaries.

Closes #3350
2019-11-26 18:35:32 +01:00
Gina Häußge 2801da5c51 💚 Fix unit tests by fixing mocked functions
Closes #3348
2019-11-26 16:22:08 +01:00
Gina Häußge 471dab9406 🐛 Don't try to write None values into upload body
Closes #3349
2019-11-26 15:34:14 +01:00
Gina Häußge 1deb247ce5 🐛 Let functools.wraps do its job
Closes #3348
2019-11-26 15:14:24 +01:00
Gina Häußge 4469a2d84a 🔖 staging/devel is now 1.4.0rc2.dev, devel 1.5.0.dev 2019-11-26 10:36:18 +01:00
13 changed files with 60 additions and 44 deletions

No files matched your search

+5 -2
View File
@@ -29,5 +29,8 @@ improve/.* 1.3.13 2a42f02aecaedf2c55579984e0bc94e44402cc15 pep440-dev
staging/maintenance 1.3.12rc4 a70a45f062687beb510fb3192e4227754e1dff39 pep440-dev
regressionfix/.* 1.3.12rc4 a70a45f062687beb510fb3192e4227754e1dff39 pep440-dev
# every other branch is a development branch and thus gets resolved to 1.4.0-dev for now
.* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev
# staging/devel is currently the branch for preparation of 1.4.0rc2
staging/devel 1.4.0rc2 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
# every other branch is a development branch and thus gets resolved to 1.5.0-dev for now
.* 1.5.0 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
+1 -1
View File
@@ -107,7 +107,7 @@ class UserManager(GroupChangeListener, object):
return user
def logout_user(self, user):
if user is None or user.is_anonymous:
if user is None or user.is_anonymous or isinstance(user, AdminUser):
return
if isinstance(user, LocalProxy):
+3 -3
View File
@@ -7,7 +7,7 @@ import os
import yaml
import io
import time
from binascii import hexlify
import uuid
from collections import defaultdict
from flask_babel import gettext
@@ -381,7 +381,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
for user_id, data in self._keys.items():
if any(filter(lambda x: x.api_key == api_key, data)):
if self._user_manager.enabled:
return self._user_manager.findUser(userid=user_id)
return self._user_manager.find_user(userid=user_id)
elif user_id == "_admin" or user_id == "dummy":
# dummy = backwards compatible
return self._user_manager.anonymous_user_factory()
@@ -399,7 +399,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
return result
def _generate_key(self):
return hexlify(os.urandom(16))
return ''.join('%02X' % z for z in bytes(uuid.uuid4().bytes))
def _load_keys(self):
with self._keys_lock:
@@ -13,8 +13,8 @@ from octoprint.util.version import get_octoprint_version_string, is_released_oct
from flask import jsonify
from flask_babel import gettext
SENTRY_URL_SERVER = "https://90eab6758d324033b1523a47633d17f3@sentry.io/1373987"
SENTRY_URL_COREUI = "https://ae03048024f841fc9724c3f5c19557a4@sentry.io/1374096"
SENTRY_URL_SERVER = "https://bcd62166a2b145aa9818947bfb76706f@sentry.io/1373987"
SENTRY_URL_COREUI = "https://217a5d75940b443eaaec347bb30c128d@sentry.io/1374096"
SETTINGS_DEFAULTS = dict(enabled=False,
enabled_unreleased=False,
+25 -20
View File
@@ -590,31 +590,36 @@ def passive_login():
return u
if user is not None and user.is_active:
# login known user
logger.info("Passively logging in user {} from {}".format(user.get_id(), remote_address))
user = login(user)
def determine_user(u):
if not u.is_anonymous and u.is_active:
# known active user
logger.info("Passively logging in user {} from {}".format(u.get_id(), remote_address))
elif settings().getBoolean(["accessControl", "autologinLocal"]) \
and settings().get(["accessControl", "autologinAs"]) is not None \
and settings().get(["accessControl", "localNetworks"]) is not None \
and not "active_logout" in flask.request.cookies:
elif settings().getBoolean(["accessControl", "autologinLocal"]) \
and settings().get(["accessControl", "autologinAs"]) is not None \
and settings().get(["accessControl", "localNetworks"]) is not None \
and not "active_logout" in flask.request.cookies:
# attempt local autologin
autologin_as = settings().get(["accessControl", "autologinAs"])
local_networks = _local_networks()
logger.debug("Checking if remote address {} is in localNetworks ({!r})".format(remote_address, local_networks))
autologin_as = settings().get(["accessControl", "autologinAs"])
local_networks = _local_networks()
logger.debug("Checking if remote address {} is in localNetworks ({!r})".format(remote_address, local_networks))
try:
if netaddr.IPAddress(remote_address) in local_networks:
autologin_user = octoprint.server.userManager.find_user(autologin_as)
if autologin_user is not None and autologin_user.is_active:
logger.info("Passively logging in user {} from {} via autologin".format(autologin_as, remote_address))
return autologin_user
except Exception:
logger.exception("Could not autologin user {} from {} for networks {}".format(autologin_as, remote_address, local_networks))
try:
if netaddr.IPAddress(remote_address) in local_networks:
autologin_user = octoprint.server.userManager.findUser(autologin_as)
if autologin_user is not None and autologin_user.is_active:
autologin_user = octoprint.server.userManager.login_user(autologin_user)
if not u.is_active:
# inactive user, switch to anonymous
u = octoprint.server.userManager.anonymous_user_factory()
logger.info("Passively logging in user {} from {} via autologin".format(user.get_id(), local_networks))
user = login(autologin_user)
except Exception:
logger.exception("Could not autologin user {} for networks {}".format(autologin_as, local_networks))
return u
user = login(determine_user(user))
response = user.as_dict()
response["_is_external_client"] = ip_check_enabled and not is_lan_address(remote_address,
additional_private=ip_check_trusted)
+2
View File
@@ -460,6 +460,8 @@ class UploadStorageFallbackHandler(RequestlessExceptionLoggingMixin,
fields = dict((self._suffixes[key], value) for (key, value) in parameters.items())
for n, p in fields.items():
if n is None or p is None:
continue
key = name + b"." + octoprint.util.to_bytes(n)
self._new_body += b"--%s\r\n" % self._multipart_boundary
self._new_body += b"Content-Disposition: form-data; name=\"%s\"\r\n" % key
+1 -1
View File
@@ -159,7 +159,7 @@
return entry;
}
if (!entry.hasOwnProperty("children")) {
if (!entry.hasOwnProperty("children") || !entry.children) {
return undefined;
}
+6 -6
View File
@@ -263,7 +263,7 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
}
self._printerErrorCancelNotification = new PNotify({
title: gettext("Error reported by printer"),
text: _.sprintf(gettext("Your printer's firmware reported an error. Due to that the ongoing print job will be cancelled. Reported error: %(firmwareError)s"), _.escape(payload)),
text: _.sprintf(gettext("Your printer's firmware reported an error. Due to that the ongoing print job will be cancelled. Reported error: %(firmwareError)s"), {firmwareError: _.escape(payload.firmwareError)}),
type: "error",
hide: false
});
@@ -274,24 +274,24 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
switch (payload.reason) {
case "firmware": {
title = gettext("Error reported by printer");
text = _.sprintf(gettext("Your printer's firmware reported an error. Due to that OctoPrint will disconnect. Reported error: %(error)s"), _.escape(payload));
text = _.sprintf(gettext("Your printer's firmware reported an error. Due to that OctoPrint will disconnect. Reported error: %(error)s"), {error: _.escape(payload.error)});
break;
}
case "resend":
case "resend_loop":
case "timeout": {
title = gettext("Communication error");
text = _.sprintf(gettext("There was a communication error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), _.escape(payload));
text = _.sprintf(gettext("There was a communication error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), {error: _.escape(payload.error)});
break;
}
case "connection": {
title = gettext("Error connecting to printer");
text = _.sprintf(gettext("There was an error while trying to connect to your printer. Error: %(error)s"), _.escape(payload));
text = _.sprintf(gettext("There was an error while trying to connect to your printer. Error: %(error)s"), {error: _.escape(payload.error)});
break;
}
case "start_print": {
title = gettext("Error starting a print");
text = _.sprintf(gettext("There was an error while trying to start a print job. Error: %(error)s"), _.escape(payload));
text = _.sprintf(gettext("There was an error while trying to start a print job. Error: %(error)s"), {error: _.escape(payload.error)});
break;
}
case "autodetect_port":
@@ -301,7 +301,7 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
}
default: {
title = gettext("Unknown error");
text = _.sprintf(gettext("There was an unknown error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), _.escape(payload));
text = _.sprintf(gettext("There was an unknown error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), {error: _.escape(payload.error)});
break;
}
}
@@ -837,7 +837,7 @@ $(function() {
return element;
}
if (!element.hasOwnProperty("children")) {
if (!element.hasOwnProperty("children") || !element.children) {
return undefined;
}
@@ -157,7 +157,7 @@ $(function() {
self.userneeds({});
}
if (data.name) {
if (data && data.name) {
self.username(data.name);
self.currentUser(data);
+5 -5
View File
@@ -465,7 +465,7 @@ class Timelapse(object):
"""
Override this to perform additional actions upon start of a print job.
"""
self.start_timelapse(payload["file"])
self.start_timelapse(payload["name"])
def on_print_done(self, event, payload):
"""
@@ -478,7 +478,7 @@ class Timelapse(object):
Override this to perform additional actions upon the pausing of a print job.
"""
if not self._in_timelapse:
self.start_timelapse(payload["file"])
self.start_timelapse(payload["name"])
def event_subscriptions(self):
"""
@@ -502,14 +502,14 @@ class Timelapse(object):
"""
return None
def start_timelapse(self, gcodeFile):
self._logger.debug("Starting timelapse for %s" % gcodeFile)
def start_timelapse(self, gcode_file):
self._logger.debug("Starting timelapse for %s" % gcode_file)
self._image_number = 0
self._capture_errors = 0
self._capture_success = 0
self._in_timelapse = True
self._gcode_file = os.path.basename(gcodeFile)
self._gcode_file = os.path.basename(gcode_file)
self._file_prefix = "{}_{}".format(os.path.splitext(self._gcode_file)[0], time.strftime("%Y%m%d%H%M%S"))
def stop_timelapse(self, do_create_movie=True, success=True):
-2
View File
@@ -131,8 +131,6 @@ def pp(value):
def warning_decorator_factory(warning_type):
def specific_warning(message, stacklevel=1, since=None, includedoc=None, extenddoc=False):
def decorator(func):
func.__qualname__ = to_native_str('warning_decorator_factory')
func.__annotations__ = dict()
@wraps(func)
def func_wrapper(*args, **kwargs):
# we need to increment the stacklevel by one because otherwise we'll get the location of our
+8
View File
@@ -105,7 +105,11 @@ class SettingsTestCase(unittest.TestCase):
def test_deprecated_forwarded_getter(self, deprecated, current, forwarded):
with warnings.catch_warnings(record=True) as w:
called_method = getattr(self.settings, forwarded)
# further mock out our mocked function so things work as they should
called_method.__name__ = to_native_str(forwarded)
called_method.__qualname__ = to_native_str(forwarded)
called_method.__annotations__ = dict()
method = getattr(self.plugin_settings, deprecated)
self.assertTrue(callable(method))
@@ -169,7 +173,11 @@ class SettingsTestCase(unittest.TestCase):
def test_deprecated_forwarded_setter(self, deprecated, current, forwarded, value):
with warnings.catch_warnings(record=True) as w:
called_method = getattr(self.settings, forwarded)
# further mock out our mocked function so things work as they should
called_method.__name__ = to_native_str(forwarded)
called_method.__qualname__ = to_native_str(forwarded)
called_method.__annotations__ = dict()
method = getattr(self.plugin_settings, deprecated)
self.assertTrue(callable(method))