Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e603b98d0d | ||
|
|
e235fc299f | ||
|
|
4f25ed546e | ||
|
|
f72b9db6a9 | ||
|
|
80e8e33283 | ||
|
|
00d0396417 | ||
|
|
59e39662f1 | ||
|
|
038e1b9a57 | ||
|
|
bbefeeeb02 | ||
|
|
2801da5c51 | ||
|
|
471dab9406 | ||
|
|
1deb247ce5 | ||
|
|
4469a2d84a |
No files matched your search
+5
-2
@@ -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
|
||||
@@ -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):
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
return entry;
|
||||
}
|
||||
|
||||
if (!entry.hasOwnProperty("children")) {
|
||||
if (!entry.hasOwnProperty("children") || !entry.children) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in new issue
Block a user