From 687b449207848cfc6b001649aa178987c970c398 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Sat, 28 Jul 2018 23:12:59 +0200
Subject: [PATCH 001/183] SWU: Prevent auto updates in outdated environments
We will now demand minimum versions of Python, pip and setuptools to be
present before we enable updating through the plugin.
Current minimum versions are those shipped with stock OctoPi 0.14.0.
---
.../plugins/softwareupdate/__init__.py | 52 +++++++++++++++++--
.../static/js/softwareupdate.js | 18 ++++++-
.../templates/softwareupdate_settings.jinja2 | 19 ++++++-
.../plugins/softwareupdate/updaters/pip.py | 8 ++-
src/octoprint/server/util/flask.py | 18 ++++---
5 files changed, 102 insertions(+), 13 deletions(-)
diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py
index 2166d293b..c6a08208e 100644
--- a/src/octoprint/plugins/softwareupdate/__init__.py
+++ b/src/octoprint/plugins/softwareupdate/__init__.py
@@ -27,9 +27,16 @@ from flask_babel import gettext
from octoprint.server.util.flask import restricted_access, with_revalidation_checking, check_etag
from octoprint.server import admin_permission, VERSION, REVISION, BRANCH
from octoprint.util import dict_merge, to_unicode
+from octoprint.util.version import get_comparable_version
+from octoprint.util.pip import LocalPipCaller
import octoprint.settings
+MINIMUM_PYTHON = "2.7.9"
+MINIMUM_SETUPTOOLS = "5.5.1"
+MINIMUM_PIP = "9.0.1"
+
+
##~~ Plugin
@@ -43,7 +50,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
COMMIT_TRACKING_TYPES = ("github_commit", "bitbucket_commit")
- DATA_FORMAT_VERSION = "v3"
+ DATA_FORMAT_VERSION = "v4"
# noinspection PyMissingConstructor
def __init__(self):
@@ -62,6 +69,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
self._version_cache_dirty = False
self._version_cache_timestamp = None
+ self._environment_supported = False
+ self._environment_versions = dict()
+ self._environment_ready = threading.Event()
+
self._console_logger = None
def initialize(self):
@@ -92,6 +103,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
# the server startup
def fetch_data():
self.get_current_versions()
+ self._check_environment()
thread = threading.Thread(target=fetch_data)
thread.daemon = True
@@ -165,6 +177,24 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
return self._configured_checks
+ def _check_environment(self):
+ from platform import python_version
+ import pkg_resources
+
+ local_pip = LocalPipCaller()
+
+ # check python and setuptools version
+ versions = dict(python=python_version(),
+ setuptools=pkg_resources.get_distribution("setuptools").version,
+ pip=local_pip.version_string)
+ supported = get_comparable_version(versions["python"]) >= get_comparable_version(MINIMUM_PYTHON) \
+ and get_comparable_version(versions["setuptools"]) >= get_comparable_version(MINIMUM_SETUPTOOLS) \
+ and get_comparable_version(versions["pip"]) >= get_comparable_version(MINIMUM_PIP)
+
+ self._environment_supported = supported
+ self._environment_versions = versions
+ self._environment_ready.set()
+
def _load_version_cache(self):
if not os.path.isfile(self._version_cache_path):
return
@@ -483,11 +513,17 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
force = flask.request.values.get("force", "false") in octoprint.settings.valid_boolean_trues
def view():
+ self._environment_ready.wait()
+
try:
information, update_available, update_possible = self.get_current_versions(check_targets=check_targets, force=force)
- return flask.jsonify(dict(status="inProgress" if self._update_in_progress else "updatePossible" if update_available and update_possible else "updateAvailable" if update_available else "current",
+ return flask.jsonify(dict(status="inProgress" if self._update_in_progress else "updatePossible" if update_available and update_possible and self._environment_supported else "updateAvailable" if update_available else "current",
information=information,
- timestamp=self._version_cache_timestamp))
+ timestamp=self._version_cache_timestamp,
+ environment=dict(supported=self._environment_supported,
+ versions=[dict(name=gettext("Python"), current=self._environment_versions.get("python", "unknown"), minimum=MINIMUM_PYTHON),
+ dict(name=gettext("pip"), current=self._environment_versions.get("pip", "unknown"), minimum=MINIMUM_PIP),
+ dict(name=gettext("setuptools"), current=self._environment_versions.get("setuptools", "unknown"), minimum=MINIMUM_SETUPTOOLS)])))
except exceptions.ConfigurationInvalid as e:
return flask.make_response("Update not properly configured, can't proceed: %s" % e.message, 500)
@@ -514,6 +550,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
hash.update(str(data.get("online", None)))
hash.update(",".join(targets))
+
+ hash.update(str(self._environment_supported))
hash.update(str(self._version_cache_timestamp))
hash.update(str(self._connectivity_checker.online))
hash.update(str(self._update_in_progress))
@@ -536,6 +574,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
# do not update while a print job is running
return flask.make_response("Printer is currently printing or paused", 409)
+ if not self._environment_supported:
+ return flask.make_response("Direct updates are not supported in this Python environment", 409)
+
if not "application/json" in flask.request.headers["Content-Type"]:
return flask.make_response("Expected content-type JSON", 400)
@@ -646,6 +687,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
continue
target_information, target_update_available, target_update_possible, target_online, target_error = future.result()
+ target_update_possible = target_update_possible and self._environment_supported
target_information = dict_merge(dict(local=dict(name="?", value="?"),
remote=dict(name="?", value="?",
@@ -779,6 +821,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
:param targets: an iterable defining the targets to update, if not supplied defaults to all targets
"""
+ if not self._environment_supported:
+ self._logger.error("Direct updates are unsupported in this environment")
+ return [], dict()
+
targets = kwargs.get("targets", kwargs.get("check_targets", None))
checks = self._get_configured_checks()
diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
index d0484a5b8..b9aee68cc 100644
--- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
+++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
@@ -116,6 +116,9 @@ $(function() {
&& !self.octoprintReleasedVersion();
});
+ self.environmentSupported = ko.observable(true);
+ self.environmentVersions = ko.observableArray([]);
+
self.cacheTimestamp = ko.observable();
self.cacheTimestampText = ko.pureComputed(function() {
return formatDate(self.cacheTimestamp());
@@ -132,6 +135,10 @@ $(function() {
&& (!self.config_checkoutFolder() || self.config_checkoutFolder().trim() === '');
});
+ self.enableUpdate = ko.pureComputed(function() {
+ return !self.updateInProgress && self.environmentSupported();
+ });
+
self.enable_configSave = ko.pureComputed(function() {
return self.config_checkType() === "github_release"
|| (self.config_checkType() === "git_commit" && !self.error_checkoutFolder());
@@ -300,6 +307,9 @@ $(function() {
var octoprint = data.information["octoprint"];
self.octoprintReleasedVersion(!octoprint || octoprint.released_version);
+ self.environmentSupported(data.environment.supported);
+ self.environmentVersions(data.environment.versions);
+
if (data.status === "inProgress") {
self._markWorking(gettext("Updating..."), gettext("Updating, please wait."));
return;
@@ -314,7 +324,7 @@ $(function() {
_.each(self.versions.items(), function(update_info) {
if (update_info.updateAvailable) {
text += ""
- + " "
+ + " "
+ "" + update_info.fullNameRemote + " "
+ (update_info.releaseNotes ? "" + gettext("Release Notes") + " " : "")
+ " ";
@@ -322,7 +332,11 @@ $(function() {
});
text += "";
- text += "" + gettext("Those components marked with can be updated directly.") + "
";
+ if (!self.environmentSupported()) {
+ text += "" + gettext("This version of the Python environment is not supported for direct updates.") + "
";
+ } else {
+ text += "" + gettext("Those components marked with can be updated directly.") + "
";
+ }
if (!self.loginState.isAdmin()) {
text += "" + gettext("To have updates applied, get in touch with an administrator of this OctoPrint instance.") + "
";
diff --git a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2
index df803fd92..13b5c5313 100644
--- a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2
+++ b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2
@@ -15,6 +15,23 @@
Documentation .
{% endtrans %}
+{% trans %}
+
+ This version of the Python environment is not supported for direct updates.
+
+
+ To reduce the likelihood of running into update problems in outdated environments, the following minimal
+ versions are required to use this updater to update OctoPrint or any installed plugins:
+
+{% endtrans %}
+
+ : ({{ _('you have') }}: )
+
+{% trans %}
+
+ Please take a look at this FAQ entry on how to proceed .
+
+{% endtrans %}
@@ -59,7 +76,7 @@
- {{ _('Update all') }}
+ {{ _('Update all') }}
{{ _('Check for update now') }}
diff --git a/src/octoprint/plugins/softwareupdate/updaters/pip.py b/src/octoprint/plugins/softwareupdate/updaters/pip.py
index 08dfed097..fb970144f 100644
--- a/src/octoprint/plugins/softwareupdate/updaters/pip.py
+++ b/src/octoprint/plugins/softwareupdate/updaters/pip.py
@@ -10,6 +10,7 @@ import logging
import pkg_resources
from octoprint.util.pip import PipCaller, UnknownPip
+from octoprint.util.version import get_comparable_version
from .. import exceptions
logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip")
@@ -23,8 +24,13 @@ _pip_callers = dict()
_pip_version_dependency_links = pkg_resources.parse_version("1.5")
def can_perform_update(target, check, online=True):
+ from .. import MINIMUM_PIP
pip_caller = _get_pip_caller(command=check["pip_command"] if "pip_command" in check else None)
- return "pip" in check and pip_caller is not None and pip_caller.available and (online or check.get("offline", False))
+ return "pip" in check \
+ and pip_caller is not None \
+ and pip_caller.available \
+ and pip_caller.version >= get_comparable_version(MINIMUM_PIP) \
+ and (online or check.get("offline", False))
def _get_pip_caller(command=None):
key = command
diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py
index 2ab536e36..792a6d8e1 100644
--- a/src/octoprint/server/util/flask.py
+++ b/src/octoprint/server/util/flask.py
@@ -1120,28 +1120,34 @@ def redirect_to_tornado(request, target, code=302):
def restricted_access(func):
+ """
+ This combines :py:func:`no_firstrun_access` and ``login_required``.
+ """
+ @functools.wraps(func)
+ def decorated_view(*args, **kwargs):
+ return no_firstrun_access(flask_login.login_required(func))(*args, **kwargs)
+ return decorated_view
+
+def no_firstrun_access(func):
"""
If you decorate a view with this, it will ensure that first setup has been
- done for OctoPrint's Access Control plus that any conditions of the
- login_required decorator are met (possibly through a session already created
- by octoprint.server.util.apiKeyRequestHandler earlier in the request processing).
+ done for OctoPrint's Access Control.
If OctoPrint's Access Control has not been setup yet (indicated by the "firstRun"
flag from the settings being set to True and the userManager not indicating
that it's user database has been customized from default), the decorator
will cause a HTTP 403 status code to be returned by the decorated resource.
"""
+
@functools.wraps(func)
def decorated_view(*args, **kwargs):
# if OctoPrint hasn't been set up yet, abort
if settings().getBoolean(["server", "firstRun"]) and settings().getBoolean(["accessControl", "enabled"]) and (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()):
return flask.make_response("OctoPrint isn't setup yet", 403)
-
- return flask_login.login_required(func)(*args, **kwargs)
+ return func(*args, **kwargs)
return decorated_view
-
def firstrun_only_access(func):
"""
If you decorate a view with this, it will ensure that first setup has _not_ been
From 909dd551d6246b60760c26bbb6aaf448e3a21ef0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Sat, 28 Jul 2018 23:30:43 +0200
Subject: [PATCH 002/183] Specify support python versions
---
setup.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/setup.py b/setup.py
index ba2412f48..9b3135e15 100644
--- a/setup.py
+++ b/setup.py
@@ -12,6 +12,9 @@ import octoprint_setuptools
#-----------------------------------------------------------------------------------------------------------------------
+# Supported python versions
+PYTHON_REQUIRES = ">=2.7.3,<3" # TODO change to >=2.7.9,<3 in 1.3.11
+
# Requirements for our application
INSTALL_REQUIRES = [
"flask>=0.10.1,<0.11",
@@ -154,6 +157,7 @@ def params():
long_description = read_file_contents(os.path.join(here, "README.md"))
long_description_content_type = "text/markdown"
+ python_requires = PYTHON_REQUIRES
install_requires = INSTALL_REQUIRES
extras_require = EXTRA_REQUIRES
dependency_links = DEPENDENCY_LINKS
From a137946e3a02d568bc125a49a1daf303cdc77782 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Sat, 28 Jul 2018 23:36:28 +0200
Subject: [PATCH 003/183] Remove setup_requires - it's incompatible to pip
---
setup.py | 4 ----
1 file changed, 4 deletions(-)
diff --git a/setup.py b/setup.py
index 9b3135e15..0c48481af 100644
--- a/setup.py
+++ b/setup.py
@@ -82,9 +82,6 @@ EXTRA_REQUIRES = dict(
]
)
-# Additional requirements for setup
-SETUP_REQUIRES = []
-
# Dependency links for any of the aforementioned dependencies
DEPENDENCY_LINKS = []
@@ -161,7 +158,6 @@ def params():
install_requires = INSTALL_REQUIRES
extras_require = EXTRA_REQUIRES
dependency_links = DEPENDENCY_LINKS
- setup_requires = SETUP_REQUIRES
classifiers = [
"Development Status :: 5 - Production/Stable",
From 25cd4f8201fc09352ba947e41fe4ec3c3175a336 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 24 Aug 2018 11:58:56 +0200
Subject: [PATCH 004/183] Add no_firstrun_access decorator
---
src/octoprint/server/util/flask.py | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py
index 2ab536e36..8cca9c541 100644
--- a/src/octoprint/server/util/flask.py
+++ b/src/octoprint/server/util/flask.py
@@ -1133,11 +1133,7 @@ def restricted_access(func):
"""
@functools.wraps(func)
def decorated_view(*args, **kwargs):
- # if OctoPrint hasn't been set up yet, abort
- if settings().getBoolean(["server", "firstRun"]) and settings().getBoolean(["accessControl", "enabled"]) and (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()):
- return flask.make_response("OctoPrint isn't setup yet", 403)
-
- return flask_login.login_required(func)(*args, **kwargs)
+ return flask_login.login_required(no_firstrun_access(func))(*args, **kwargs)
return decorated_view
@@ -1159,6 +1155,24 @@ def firstrun_only_access(func):
return decorated_view
+def no_firstrun_access(func):
+ """
+ If you decorate a view with this, it will ensure that first setup as been done for
+ OctoPrint's Access Control. Otherwise it
+ will cause a HTTP 403 status code to be returned by the decorated resource.
+ """
+
+ @functools.wraps(func)
+ def decorated_view(*args, **kwargs):
+ # if OctoPrint hasn't been set up yet, abort
+ if settings().getBoolean(["server", "firstRun"]) and settings().getBoolean(["accessControl", "enabled"]) and \
+ (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()):
+ return flask.make_response("OctoPrint isn't setup yet", 403)
+ return func(*args, **kwargs)
+
+ return decorated_view
+
+
class AppSessionManager(object):
VALIDITY_UNVERIFIED = 1 * 60 # 1 minute
From 5a5785be4aa11c963068a7f7cac82cf3bcac3425 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 24 Aug 2018 11:59:23 +0200
Subject: [PATCH 005/183] Appauth plugin: WIP
---
src/octoprint/plugins/appauth/__init__.py | 269 ++++++++++++++++++
.../plugins/appauth/static/js/appauth.js | 169 +++++++++++
.../templates/appauth_usersettings.jinja2 | 42 +++
3 files changed, 480 insertions(+)
create mode 100644 src/octoprint/plugins/appauth/__init__.py
create mode 100644 src/octoprint/plugins/appauth/static/js/appauth.js
create mode 100644 src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
diff --git a/src/octoprint/plugins/appauth/__init__.py b/src/octoprint/plugins/appauth/__init__.py
new file mode 100644
index 000000000..08d0bcf6b
--- /dev/null
+++ b/src/octoprint/plugins/appauth/__init__.py
@@ -0,0 +1,269 @@
+# coding=utf-8
+from __future__ import absolute_import
+
+import flask
+import threading
+import os
+from binascii import hexlify
+from collections import defaultdict
+
+import octoprint.plugin
+from octoprint.settings import valid_boolean_trues
+from octoprint.server.util.flask import restricted_access, no_firstrun_access
+from octoprint.server import NO_CONTENT, current_user, user_permission
+
+
+class AppAlreadyExists(Exception):
+ pass
+
+
+class PendingDecision(object):
+ def __init__(self, app_id, app_token, user_id, user_token):
+ self.app_id = app_id
+ self.app_token = app_token
+ self.user_id = user_id
+ self.user_token = user_token
+
+ def external(self):
+ return dict(app_id=self.app_id,
+ user_id=self.user_id,
+ user_token=self.user_token)
+
+
+class ReadyDecision(object):
+ def __init__(self, app_id, app_token, user_id, api_key):
+ self.app_id = app_id
+ self.app_token = app_token
+ self.user_id = user_id
+ self.api_key = api_key
+
+ @classmethod
+ def for_pending(cls, pending, api_key):
+ return cls(pending.app_id, pending.app_token, pending.user_id, api_key)
+
+
+class ActiveKey(object):
+ def __init__(self, app_id, api_key):
+ self.app_id = app_id
+ self.api_key = api_key
+
+ def external(self):
+ return dict(app_id=self.app_id,
+ api_key=self.api_key)
+
+
+class AppAuthPlugin(octoprint.plugin.AssetPlugin,
+ octoprint.plugin.BlueprintPlugin,
+ octoprint.plugin.SimpleApiPlugin,
+ octoprint.plugin.TemplatePlugin):
+
+ def __init__(self):
+ self._pending_decisions = []
+ self._pending_lock = threading.RLock()
+
+ self._ready_decisions = []
+ self._ready_lock = threading.RLock()
+
+ self._keys = defaultdict(list)
+ self._keys_lock = threading.RLock()
+
+ ##-- AssetPlugin hooks
+
+ def get_assets(self):
+ return dict(js=["js/appauth.js"])
+
+ ##~~ BlueprintPlugin mixin
+
+ @octoprint.plugin.BlueprintPlugin.route("/request", methods=["POST"])
+ @no_firstrun_access
+ def handle_request(self):
+ data = flask.request.json
+ if not "app" in data:
+ return flask.make_response("No app name provided", 400)
+
+ app_name = data["app"]
+ user_id = None
+ if "user" in data:
+ user_id = data["user"]
+
+ app_token, user_token = self._add_pending_decision(app_name, user_id=user_id)
+
+ self._plugin_manager.send_plugin_message(self._identifier, dict(type="request_access",
+ app_name=app_name,
+ user_token=user_token,
+ user_id=user_id))
+ response = flask.jsonify(app_token=app_token)
+ response.status_code = 202
+ response.headers["Location"] = flask.url_for(".handle_decision_poll", app_token=app_token, _external=True)
+ return response
+
+ @octoprint.plugin.BlueprintPlugin.route("/request/")
+ @no_firstrun_access
+ def handle_decision_poll(self, app_token):
+ if self._is_pending(app_token):
+ return flask.make_response("Awaiting decision", 202)
+
+ result = self._get_decision(app_token)
+ if result is not None:
+ return flask.jsonify(api_key=result)
+
+ return flask.abort(404)
+
+ @octoprint.plugin.BlueprintPlugin.route("/decision/", methods=["POST"])
+ @restricted_access
+ def handle_decision(self, user_token):
+ data = flask.request.json
+ if not "decision" in data:
+ return flask.make_response("No decision provided", 400)
+ decision = data["decision"] in valid_boolean_trues
+ user_id = current_user.get_name()
+
+ result = self._set_decision(user_token, decision, user_id)
+ if not result:
+ return flask.abort(404)
+
+ return NO_CONTENT
+
+ def is_blueprint_protected(self):
+ return False # No API key required to request API access
+
+ ##~~ SimpleApiPlugin mixin
+
+ def get_api_commands(self):
+ return dict(generate=["app"],
+ revoke=["key"])
+
+ def on_api_get(self, request):
+ user_id = current_user.get_name()
+ if not user_id:
+ return flask.abort(403)
+
+ return flask.jsonify(keys=map(lambda x: x.external(), self._api_keys_for_user(user_id)),
+ pending=dict((x.user_token, x.external()) for x in self._get_pending(user_id)))
+
+ def on_api_command(self, command, data):
+ user_id = current_user.get_name()
+ if not user_id:
+ return flask.abort(403)
+
+ if command == "revoke":
+ api_key = data.get("key")
+ if not api_key:
+ return flask.abort(400)
+
+ self._delete_api_key(user_id, api_key)
+
+ elif command == "generate":
+ # manual generateKey
+ app_name = data.get("app")
+ if not app_name:
+ return flask.abort(400)
+
+ api_key = self._generate_key()
+ try:
+ self._add_api_key(user_id, app_name.trim(), api_key)
+ except AppAlreadyExists:
+ return flask.abort(409)
+
+ return NO_CONTENT
+
+ ##~~ key validator hook
+
+ def validate_api_key(self, api_key, *args, **kwargs):
+ return self._user_for_api_key(api_key)
+
+ ##~~ Helpers
+
+ def _add_pending_decision(self, app_name, user_id=None):
+ app_token = self._generate_key()
+ user_token = self._generate_key()
+
+ with self._pending_lock:
+ self._pending_decisions.append(PendingDecision(app_name, app_token, user_id, user_token))
+
+ return app_token, user_token
+
+ def _is_pending(self, app_token):
+ with self._pending_lock:
+ for data in self._pending_decisions:
+ if data.app_token == app_token:
+ return True
+
+ return False
+
+ def _get_pending(self, user_id):
+ result = []
+ with self._pending_lock:
+ for data in self._pending_decisions:
+ if data.user_id == user_id or data.user_id is None:
+ result.append(data)
+ return result
+
+ def _set_decision(self, user_token, decision, user_id):
+ with self._pending_lock:
+ for data in self._pending_decisions:
+ if data.user_token == user_token and (data.user_id == user_id or data.user_id is None):
+ pending = data
+ break
+ else:
+ return False # not found
+
+ if decision:
+ with self._ready_lock:
+ self._ready_decisions.append(ReadyDecision.for_pending(pending, self._generate_key()))
+
+ with self._pending_lock:
+ self._pending_decisions = filter(lambda x: x.user_token != user_token, self._pending_decisions)
+
+ return True
+
+ def _get_decision(self, app_token):
+ with self._ready_lock:
+ for data in self._ready_decisions:
+ if data.app_token == app_token:
+ decision = data
+ break
+ else:
+ return False # not found
+
+ self._add_api_key(decision.user_id, decision.app_id, decision.api_key)
+
+ with self._ready_lock:
+ self._ready_decisions = filter(lambda x: x.app_token != app_token, self._ready_decisions)
+
+ return decision.api_key
+
+ def _add_api_key(self, user_id, app_name, api_key):
+ with self._keys_lock:
+ # TODO: persist to disk
+ for key in self._keys[user_id]:
+ if key.app_id.lower() == app_name.lower():
+ raise AppAlreadyExists("app {} does already exist".format(app_name))
+ self._keys[user_id].append(ActiveKey(app_name, api_key))
+
+ def _delete_api_key(self, user_id, api_key):
+ with self._keys_lock:
+ # TODO: persist to disk
+ self._keys[user_id] = filter(lambda x: x.api_key != api_key, self._keys[user_id])
+
+ def _user_for_api_key(self, api_key):
+ with self._keys_lock:
+ for user_id, data in self._keys.items():
+ if filter(lambda x: x.api_key == api_key, data):
+ return self._user_manager.findUser(userid=user_id)
+ return None
+
+ def _api_keys_for_user(self, user_id):
+ with self._keys_lock:
+ return self._keys.get(user_id, [])
+
+ def _generate_key(self):
+ return hexlify(os.urandom(16))
+
+__plugin_name__ = "AppAuth Plugin"
+__plugin_description__ = "TODO"
+__plugin_author__ = "Gina Häußge, Aldo Hoeben"
+__plugin_implementation__ = AppAuthPlugin()
+__plugin_hooks__ = {
+ "octoprint.accesscontrol.keyvalidator": __plugin_implementation__.validate_api_key
+}
diff --git a/src/octoprint/plugins/appauth/static/js/appauth.js b/src/octoprint/plugins/appauth/static/js/appauth.js
new file mode 100644
index 000000000..74ec1e6e1
--- /dev/null
+++ b/src/octoprint/plugins/appauth/static/js/appauth.js
@@ -0,0 +1,169 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintAppAuthClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintAppAuthClient.prototype.getKeys = function(opts) {
+ return this.base.simpleApiGet("appauth", opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.generateKey = function(app, opts) {
+ return this.base.simpleApiCommand("appauth", "generate", {"app": app}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.revokeKey = function(key, opts) {
+ return this.base.simpleApiCommand("appauth", "revoke", {"key": key}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.decide = function(token, decision, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appauth") + "decision/" + token, {decision: !!decision}, opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("appauth", OctoPrintAppAuthClient);
+ return OctoPrintAppAuthClient;
+});
+
+$(function() {
+ function AppAuthViewModel(parameters) {
+ var self = this;
+ self.loginState = parameters[0];
+
+ self.keys = new ItemListHelper(
+ "plugin.appauth.keys",
+ {
+ "app": function (a, b) {
+ // sorts descending
+ if (a["app"] > b["app"]) return -1;
+ if (a["app"] < b["app"]) return 1;
+ return 0;
+ }
+ },
+ {
+ },
+ "app",
+ [],
+ [],
+ 10
+ );
+ self.pending = {};
+ self.openRequests = {};
+
+ self.editorApp = ko.observable();
+
+ self.requestData = function() {
+ OctoPrint.plugins.appauth.getKeys()
+ .done(self.fromResponse);
+ };
+
+ self.fromResponse = function(response) {
+ self.keys.updateItems(response.keys);
+ self.pending = response.pending;
+ _.each(self.pending, function(data, token) {
+ self.openRequests[token] = self.promptForAccess(data.app_id, token);
+ })
+ };
+
+ self.generateKey = function() {
+ return OctoPrint.plugins.appauth.generateKey(self.editorApp())
+ .done(self.requestData);
+ };
+
+ self.revokeKey = function(key) {
+ return OctoPrint.plugins.appauth.revokeKey(key)
+ .done(self.requestData);
+ };
+
+ self.allowApp = function(token) {
+ return OctoPrint.plugins.appauth.decide(token, true)
+ .done(self.requestData);
+ };
+
+ self.denyApp = function(token) {
+ return OctoPrint.plugins.appauth.decide(token, false)
+ .done(self.requestData);
+ };
+
+ self.promptForAccess = function(app, token) {
+ var message = gettext("\"%(app)s\" has requested access to control OctoPrint through the API. Do you want to allow access to this application with your user account?");
+ message = _.sprintf(message, {app: app});
+
+ return new PNotify({
+ title: gettext("Access Request"),
+ text: message,
+ confirm: {
+ confirm: true,
+ buttons: [{
+ text: gettext("Allow"),
+ click: function(notice) {
+ self.allowApp(token);
+ }
+ }, {
+ text: gettext("Deny"),
+ click: function(notice) {
+ self.denyApp(token);
+ }
+ }]
+ },
+ buttons: {
+ sticker: false,
+ closer: false
+ }
+ });
+ };
+
+ self.onUserSettingsShown = function() {
+ self.requestData();
+ };
+
+ self.onUserLoggedIn = function() {
+ self.requestData();
+ };
+
+ self.onDataUpdaterPluginMessage = function(plugin, data) {
+ if (plugin !== "appauth") {
+ return;
+ }
+
+ var app, token, user;
+
+ if (data.type === "request_access" && self.loginState.isUser()) {
+ app = data.app_name;
+ token = data.user_token;
+ user = data.user_id;
+
+ if (user && user !== self.loginState.username()) {
+ return;
+ }
+
+ if (self.pending[token] === undefined) {
+ return;
+ }
+
+ self.openRequests[token] = self.promptForAccess(app, token);
+
+ } else if (data.type === "end_request") {
+ token = data.user_token;
+
+ if (self.openRequests[token] !== undefined) {
+ // another instance responded to the access request before the current user did
+ if (self.openRequests[token].state !== "closed") {
+ self.openRequests[token].remove();
+ }
+ delete self.openRequests[token]
+ }
+ }
+ };
+ }
+
+ OCTOPRINT_VIEWMODELS.push([
+ AppAuthViewModel,
+ ["loginStateViewModel"],
+ ["#usersettings_plugin_appauth"]
+ ]);
+});
diff --git a/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2 b/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
new file mode 100644
index 000000000..aeb2f9e67
--- /dev/null
+++ b/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
@@ -0,0 +1,42 @@
+
+
+
+ {{ _('Application') }}
+ {{ _('Action') }}
+
+
+
+
+ {{ _('API Key') }}:
+
+
+
+
+
+
+
+
+
From 2a79d9183ab3afa685ede4dcac61269f1bc4955d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Tue, 28 Aug 2018 22:02:18 +0200
Subject: [PATCH 006/183] New asset type "clientjs" for client library bits
---
.../plugins/action_command_prompt/__init__.py | 3 +-
.../static/clientjs/action_command_prompt.js | 25 ++++++
.../static/js/action_command_prompt.js | 26 ------
src/octoprint/plugins/backup/__init__.py | 1 +
.../plugins/backup/static/clientjs/backup.js | 52 ++++++++++++
.../plugins/backup/static/js/backup.js | 53 ------------
src/octoprint/plugins/logging/__init__.py | 1 +
.../logging/static/clientjs/logging.js | 68 +++++++++++++++
.../plugins/logging/static/js/logging.js | 69 ---------------
src/octoprint/plugins/pi_support/__init__.py | 1 +
.../pi_support/static/clientjs/pi_support.js | 19 +++++
.../pi_support/static/js/pi_support.js | 19 -----
.../plugins/pluginmanager/__init__.py | 1 +
.../static/clientjs/pluginmanager.js | 82 ++++++++++++++++++
.../pluginmanager/static/js/pluginmanager.js | 83 ------------------
.../plugins/printer_safety_check/__init__.py | 1 +
.../static/clientjs/printer_safety_check.js | 18 ++++
.../static/js/printer_safety_check.js | 19 -----
.../plugins/softwareupdate/__init__.py | 1 +
.../static/clientjs/softwareupdate.js | 84 ++++++++++++++++++
.../static/js/softwareupdate.js | 85 -------------------
src/octoprint/server/__init__.py | 47 +++++-----
src/octoprint/server/util/flask.py | 29 +++++++
23 files changed, 410 insertions(+), 377 deletions(-)
create mode 100644 src/octoprint/plugins/action_command_prompt/static/clientjs/action_command_prompt.js
create mode 100644 src/octoprint/plugins/backup/static/clientjs/backup.js
create mode 100644 src/octoprint/plugins/logging/static/clientjs/logging.js
create mode 100644 src/octoprint/plugins/pi_support/static/clientjs/pi_support.js
create mode 100644 src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js
create mode 100644 src/octoprint/plugins/printer_safety_check/static/clientjs/printer_safety_check.js
create mode 100644 src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js
diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py
index 0dd9a4be2..8900c5d7a 100644
--- a/src/octoprint/plugins/action_command_prompt/__init__.py
+++ b/src/octoprint/plugins/action_command_prompt/__init__.py
@@ -49,7 +49,8 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin,
#~ AssetPlugin
def get_assets(self):
- return dict(js=["js/action_command_prompt.js"])
+ return dict(js=["js/action_command_prompt.js"],
+ clientjs=["clientjs/action_command_prompt.js"])
#~ SettingsPlugin
diff --git a/src/octoprint/plugins/action_command_prompt/static/clientjs/action_command_prompt.js b/src/octoprint/plugins/action_command_prompt/static/clientjs/action_command_prompt.js
new file mode 100644
index 000000000..9ba9b4a14
--- /dev/null
+++ b/src/octoprint/plugins/action_command_prompt/static/clientjs/action_command_prompt.js
@@ -0,0 +1,25 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintActionCommandPromptClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintActionCommandPromptClient.prototype.get = function(refresh, opts) {
+ return this.base.get(this.base.getSimpleApiUrl("action_command_prompt"), opts);
+ };
+
+ OctoPrintActionCommandPromptClient.prototype.select = function(choice, opts) {
+ var data = {
+ choice: choice
+ };
+ return this.base.simpleApiCommand("action_command_prompt", "select", data, opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("action_command_prompt", OctoPrintActionCommandPromptClient);
+ return OctoPrintActionCommandPromptClient;
+});
diff --git a/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js b/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js
index 6298a5338..e077903a2 100644
--- a/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js
+++ b/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js
@@ -1,29 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintActionCommandPromptClient = function(base) {
- this.base = base;
- };
-
- OctoPrintActionCommandPromptClient.prototype.get = function(refresh, opts) {
- return this.base.get(this.base.getSimpleApiUrl("action_command_prompt"), opts);
- };
-
- OctoPrintActionCommandPromptClient.prototype.select = function(choice, opts) {
- var data = {
- choice: choice
- };
- return this.base.simpleApiCommand("action_command_prompt", "select", data, opts);
- };
-
- OctoPrintClient.registerPluginComponent("action_command_prompt", OctoPrintActionCommandPromptClient);
- return OctoPrintActionCommandPromptClient;
-});
-
$(function() {
function ActionCommandPromptViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py
index 47ceb0a31..e687b3b85 100644
--- a/src/octoprint/plugins/backup/__init__.py
+++ b/src/octoprint/plugins/backup/__init__.py
@@ -69,6 +69,7 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin,
def get_assets(self):
return dict(js=["js/backup.js"],
+ clientjs=["clientjs/backup.js"],
css=["css/backup.css"],
less=["less/backup.less"])
diff --git a/src/octoprint/plugins/backup/static/clientjs/backup.js b/src/octoprint/plugins/backup/static/clientjs/backup.js
new file mode 100644
index 000000000..5f2ee6e62
--- /dev/null
+++ b/src/octoprint/plugins/backup/static/clientjs/backup.js
@@ -0,0 +1,52 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintBackupClient = function(base) {
+ this.base = base;
+ this.url = this.base.getBlueprintUrl("backup");
+ };
+
+ OctoPrintBackupClient.prototype.get = function(refresh, opts) {
+ return this.base.get(this.url, opts);
+ };
+
+ OctoPrintBackupClient.prototype.createBackup = function(exclude, opts) {
+ exclude = exclude || [];
+
+ var data = {
+ exclude: exclude
+ };
+
+ return this.base.postJson(this.url + "backup", data, opts);
+ };
+
+ OctoPrintBackupClient.prototype.deleteBackup = function(backup, opts) {
+ return this.base.delete(this.url + "backup/" + backup, opts);
+ };
+
+ OctoPrintBackupClient.prototype.restoreBackup = function(backup, opts) {
+ var data = {
+ path: backup
+ };
+
+ return this.base.postJson(this.url + "restore", data, opts);
+ };
+
+ OctoPrintBackupClient.prototype.restoreBackupFromUpload = function (file, data) {
+ data = data || {};
+
+ var filename = data.filename || undefined;
+ return this.base.upload(this.url + "restore", file, filename, data);
+ };
+
+ OctoPrintBackupClient.prototype.deleteUnknownPlugins = function (opts) {
+ return this.base.delete(this.url + "unknown_plugins", opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("backup", OctoPrintBackupClient);
+ return OctoPrintBackupClient;
+});
diff --git a/src/octoprint/plugins/backup/static/js/backup.js b/src/octoprint/plugins/backup/static/js/backup.js
index 61eedb240..dadd24c8c 100644
--- a/src/octoprint/plugins/backup/static/js/backup.js
+++ b/src/octoprint/plugins/backup/static/js/backup.js
@@ -1,56 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintBackupClient = function(base) {
- this.base = base;
- this.url = this.base.getBlueprintUrl("backup");
- };
-
- OctoPrintBackupClient.prototype.get = function(refresh, opts) {
- return this.base.get(this.url, opts);
- };
-
- OctoPrintBackupClient.prototype.createBackup = function(exclude, opts) {
- exclude = exclude || [];
-
- var data = {
- exclude: exclude
- };
-
- return this.base.postJson(this.url + "backup", data, opts);
- };
-
- OctoPrintBackupClient.prototype.deleteBackup = function(backup, opts) {
- return this.base.delete(this.url + "backup/" + backup, opts);
- };
-
- OctoPrintBackupClient.prototype.restoreBackup = function(backup, opts) {
- var data = {
- path: backup
- };
-
- return this.base.postJson(this.url + "restore", data, opts);
- };
-
- OctoPrintBackupClient.prototype.restoreBackupFromUpload = function (file, data) {
- data = data || {};
-
- var filename = data.filename || undefined;
- return this.base.upload(this.url + "restore", file, filename, data);
- };
-
- OctoPrintBackupClient.prototype.deleteUnknownPlugins = function (opts) {
- return this.base.delete(this.url + "unknown_plugins", opts);
- };
-
- OctoPrintClient.registerPluginComponent("backup", OctoPrintBackupClient);
- return OctoPrintBackupClient;
-});
-
$(function() {
function BackupViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/logging/__init__.py b/src/octoprint/plugins/logging/__init__.py
index ed11c1c28..9b7c9bd74 100644
--- a/src/octoprint/plugins/logging/__init__.py
+++ b/src/octoprint/plugins/logging/__init__.py
@@ -195,6 +195,7 @@ class LoggingPlugin(octoprint.plugin.AssetPlugin,
def get_assets(self):
return dict(js=["js/logging.js"],
+ clientjs=["clientjs/logging.js"],
less=["less/logging.less"],
css=["css/logging.css"])
diff --git a/src/octoprint/plugins/logging/static/clientjs/logging.js b/src/octoprint/plugins/logging/static/clientjs/logging.js
new file mode 100644
index 000000000..23b90f85d
--- /dev/null
+++ b/src/octoprint/plugins/logging/static/clientjs/logging.js
@@ -0,0 +1,68 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+
+ var OctoPrintLoggingClient = function(base) {
+ this.base = base;
+
+ this.baseUrl = this.base.getBlueprintUrl("logging");
+ this.logsUrl = this.baseUrl + "logs";
+ this.setupUrl = this.baseUrl + "setup";
+ };
+
+ OctoPrintLoggingClient.prototype.get = function(opts) {
+ return this.base.get(this.baseUrl, opts);
+ };
+
+ OctoPrintLoggingClient.prototype.listLogs = function(opts) {
+ return this.base.get(this.logsUrl, opts);
+ };
+
+ OctoPrintLoggingClient.prototype.deleteLog = function(file, opts) {
+ var fileUrl = this.logsUrl + "/" + file;
+ return this.base.delete(fileUrl, opts);
+ };
+
+ OctoPrintLoggingClient.prototype.downloadLog = function(file, opts) {
+ var fileUrl = this.logsUrl + "/" + file;
+ return this.base.download(fileUrl, opts);
+ };
+
+ OctoPrintLoggingClient.prototype.updateLevels = function(config, opts) {
+ return this.base.putJson(this.setupUrl + "/levels", config, opts);
+ };
+
+ //~~ wrapper for backwards compatibility
+
+ var DeprecatedOctoPrintLogsClient = function(base) {
+ this.base = base;
+ this.wrapped = this.base.plugins.logging;
+ };
+
+ DeprecatedOctoPrintLogsClient.prototype.list = function(opts) {
+ log.warn("OctoPrintClient.logs.list has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.listLogs instead");
+ return this.wrapped.listLogs(opts);
+ };
+
+ DeprecatedOctoPrintLogsClient.prototype.delete = function(file, opts) {
+ log.warn("OctoPrintClient.logs.delete has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.deleteLog instead");
+ return this.wrapped.deleteLog(file, opts);
+ };
+
+ DeprecatedOctoPrintLogsClient.prototype.download = function(file, opts) {
+ log.warn("OctoPrintClient.logs.download has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.downloadLog instead");
+ return this.wrapped.downloadLog(file, opts);
+ };
+
+ // register plugin component
+ OctoPrintClient.registerPluginComponent("logging", OctoPrintLoggingClient);
+
+ // also register deprecated client under old endpoint
+ OctoPrintClient.registerComponent("logs", DeprecatedOctoPrintLogsClient);
+
+ return OctoPrintLoggingClient;
+});
diff --git a/src/octoprint/plugins/logging/static/js/logging.js b/src/octoprint/plugins/logging/static/js/logging.js
index c4131debb..2f0f16988 100644
--- a/src/octoprint/plugins/logging/static/js/logging.js
+++ b/src/octoprint/plugins/logging/static/js/logging.js
@@ -1,72 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
-
- var OctoPrintLoggingClient = function(base) {
- this.base = base;
-
- this.baseUrl = this.base.getBlueprintUrl("logging");
- this.logsUrl = this.baseUrl + "logs";
- this.setupUrl = this.baseUrl + "setup";
- };
-
- OctoPrintLoggingClient.prototype.get = function(opts) {
- return this.base.get(this.baseUrl, opts);
- };
-
- OctoPrintLoggingClient.prototype.listLogs = function(opts) {
- return this.base.get(this.logsUrl, opts);
- };
-
- OctoPrintLoggingClient.prototype.deleteLog = function(file, opts) {
- var fileUrl = this.logsUrl + "/" + file;
- return this.base.delete(fileUrl, opts);
- };
-
- OctoPrintLoggingClient.prototype.downloadLog = function(file, opts) {
- var fileUrl = this.logsUrl + "/" + file;
- return this.base.download(fileUrl, opts);
- };
-
- OctoPrintLoggingClient.prototype.updateLevels = function(config, opts) {
- return this.base.putJson(this.setupUrl + "/levels", config, opts);
- };
-
- //~~ wrapper for backwards compatibility
-
- var DeprecatedOctoPrintLogsClient = function(base) {
- this.base = base;
- this.wrapped = this.base.plugins.logging;
- };
-
- DeprecatedOctoPrintLogsClient.prototype.list = function(opts) {
- log.warn("OctoPrintClient.logs.list has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.listLogs instead");
- return this.wrapped.listLogs(opts);
- };
-
- DeprecatedOctoPrintLogsClient.prototype.delete = function(file, opts) {
- log.warn("OctoPrintClient.logs.delete has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.deleteLog instead");
- return this.wrapped.deleteLog(file, opts);
- };
-
- DeprecatedOctoPrintLogsClient.prototype.download = function(file, opts) {
- log.warn("OctoPrintClient.logs.download has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.downloadLog instead");
- return this.wrapped.downloadLog(file, opts);
- };
-
- // register plugin component
- OctoPrintClient.registerPluginComponent("logging", OctoPrintLoggingClient);
-
- // also register deprecated client under old endpoint
- OctoPrintClient.registerComponent("logs", DeprecatedOctoPrintLogsClient);
-
- return OctoPrintLoggingClient;
-});
-
$(function() {
function LoggingViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/pi_support/__init__.py b/src/octoprint/plugins/pi_support/__init__.py
index e0bd9ac10..28b4f3d03 100644
--- a/src/octoprint/plugins/pi_support/__init__.py
+++ b/src/octoprint/plugins/pi_support/__init__.py
@@ -193,6 +193,7 @@ class PiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin,
def get_assets(self):
return dict(
js=["js/pi_support.js"],
+ clientjs=["clientjs/pi_support.js"],
css=["css/pi_support.css"]
)
diff --git a/src/octoprint/plugins/pi_support/static/clientjs/pi_support.js b/src/octoprint/plugins/pi_support/static/clientjs/pi_support.js
new file mode 100644
index 000000000..7c216aa0f
--- /dev/null
+++ b/src/octoprint/plugins/pi_support/static/clientjs/pi_support.js
@@ -0,0 +1,19 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintPiSupportClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintPiSupportClient.prototype.get = function(opts) {
+ return this.base.get(this.base.getSimpleApiUrl("pi_support"));
+ };
+
+ OctoPrintClient.registerPluginComponent("pi_support", OctoPrintPiSupportClient);
+ return OctoPrintPiSupportClient;
+});
+
diff --git a/src/octoprint/plugins/pi_support/static/js/pi_support.js b/src/octoprint/plugins/pi_support/static/js/pi_support.js
index ced2a55e4..2516a4f77 100644
--- a/src/octoprint/plugins/pi_support/static/js/pi_support.js
+++ b/src/octoprint/plugins/pi_support/static/js/pi_support.js
@@ -1,22 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintPiSupportClient = function(base) {
- this.base = base;
- };
-
- OctoPrintPiSupportClient.prototype.get = function(opts) {
- return this.base.get(this.base.getSimpleApiUrl("pi_support"));
- };
-
- OctoPrintClient.registerPluginComponent("pi_support", OctoPrintPiSupportClient);
- return OctoPrintPiSupportClient;
-});
-
$(function() {
function PiSupportViewModel(parameters) {
diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py
index df4def7e6..c085c032e 100644
--- a/src/octoprint/plugins/pluginmanager/__init__.py
+++ b/src/octoprint/plugins/pluginmanager/__init__.py
@@ -168,6 +168,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
def get_assets(self):
return dict(
js=["js/pluginmanager.js"],
+ clientjs=["clientjs/pluginmanager.js"],
css=["css/pluginmanager.css"],
less=["less/pluginmanager.less"]
)
diff --git a/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js b/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js
new file mode 100644
index 000000000..acaaf3590
--- /dev/null
+++ b/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js
@@ -0,0 +1,82 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintPluginManagerClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintPluginManagerClient.prototype.get = function(refresh, opts) {
+ var refresh_repo, refresh_notices;
+ if (_.isPlainObject(refresh)) {
+ refresh_repo = refresh.repo || false;
+ refresh_notices = refresh.notices || false;
+ } else {
+ refresh_repo = refresh;
+ refresh_notices = false;
+ }
+
+ var query = [];
+ if (refresh_repo) query.push("refresh_repository=true");
+ if (refresh_notices) query.push("refresh_notices=true");
+
+ return this.base.get(this.base.getSimpleApiUrl("pluginmanager") + ((query.length) ? "?" + query.join("&") : ""), opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.getWithRefresh = function(opts) {
+ return this.get(true, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.getWithoutRefresh = function(opts) {
+ return this.get(false, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.install = function(pluginUrl, dependencyLinks, opts) {
+ var data = {
+ url: pluginUrl,
+ dependency_links: !!dependencyLinks
+ };
+ return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.reinstall = function(plugin, pluginUrl, dependencyLinks, opts) {
+ var data = {
+ url: pluginUrl,
+ dependency_links: !!dependencyLinks,
+ reinstall: plugin,
+ force: true
+ };
+ return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.uninstall = function(plugin, opts) {
+ var data = {
+ plugin: plugin
+ };
+ return this.base.simpleApiCommand("pluginmanager", "uninstall", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.enable = function(plugin, opts) {
+ var data = {
+ plugin: plugin
+ };
+ return this.base.simpleApiCommand("pluginmanager", "enable", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.disable = function(plugin, opts) {
+ var data = {
+ plugin: plugin
+ };
+ return this.base.simpleApiCommand("pluginmanager", "disable", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.upload = function(file) {
+ return this.base.upload(this.base.getBlueprintUrl("pluginmanager") + "upload_archive", file);
+ };
+
+ OctoPrintClient.registerPluginComponent("pluginmanager", OctoPrintPluginManagerClient);
+ return OctoPrintPluginManagerClient;
+});
diff --git a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
index 5bf20baef..403aae500 100644
--- a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
+++ b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
@@ -1,86 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintPluginManagerClient = function(base) {
- this.base = base;
- };
-
- OctoPrintPluginManagerClient.prototype.get = function(refresh, opts) {
- var refresh_repo, refresh_notices;
- if (_.isPlainObject(refresh)) {
- refresh_repo = refresh.repo || false;
- refresh_notices = refresh.notices || false;
- } else {
- refresh_repo = refresh;
- refresh_notices = false;
- }
-
- var query = [];
- if (refresh_repo) query.push("refresh_repository=true");
- if (refresh_notices) query.push("refresh_notices=true");
-
- return this.base.get(this.base.getSimpleApiUrl("pluginmanager") + ((query.length) ? "?" + query.join("&") : ""), opts);
- };
-
- OctoPrintPluginManagerClient.prototype.getWithRefresh = function(opts) {
- return this.get(true, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.getWithoutRefresh = function(opts) {
- return this.get(false, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.install = function(pluginUrl, dependencyLinks, opts) {
- var data = {
- url: pluginUrl,
- dependency_links: !!dependencyLinks
- };
- return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.reinstall = function(plugin, pluginUrl, dependencyLinks, opts) {
- var data = {
- url: pluginUrl,
- dependency_links: !!dependencyLinks,
- reinstall: plugin,
- force: true
- };
- return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.uninstall = function(plugin, opts) {
- var data = {
- plugin: plugin
- };
- return this.base.simpleApiCommand("pluginmanager", "uninstall", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.enable = function(plugin, opts) {
- var data = {
- plugin: plugin
- };
- return this.base.simpleApiCommand("pluginmanager", "enable", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.disable = function(plugin, opts) {
- var data = {
- plugin: plugin
- };
- return this.base.simpleApiCommand("pluginmanager", "disable", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.upload = function(file) {
- return this.base.upload(this.base.getBlueprintUrl("pluginmanager") + "upload_archive", file);
- };
-
- OctoPrintClient.registerPluginComponent("pluginmanager", OctoPrintPluginManagerClient);
- return OctoPrintPluginManagerClient;
-});
-
$(function() {
function PluginManagerViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/printer_safety_check/__init__.py b/src/octoprint/plugins/printer_safety_check/__init__.py
index 182f61a3e..677bef7fd 100644
--- a/src/octoprint/plugins/printer_safety_check/__init__.py
+++ b/src/octoprint/plugins/printer_safety_check/__init__.py
@@ -90,6 +90,7 @@ class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin,
def get_assets(self):
return dict(js=("js/printer_safety_check.js",),
+ clientjs=("clientjs/printer_safety_check.js",),
css=("css/printer_safety_check.css",),
less=("less/printer_safety_check.less",))
diff --git a/src/octoprint/plugins/printer_safety_check/static/clientjs/printer_safety_check.js b/src/octoprint/plugins/printer_safety_check/static/clientjs/printer_safety_check.js
new file mode 100644
index 000000000..5a52fc4f9
--- /dev/null
+++ b/src/octoprint/plugins/printer_safety_check/static/clientjs/printer_safety_check.js
@@ -0,0 +1,18 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintPrinterSafetyCheckClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintPrinterSafetyCheckClient.prototype.get = function(opts) {
+ return this.base.get(this.base.getSimpleApiUrl("printer_safety_check"), opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("printer_safety_check", OctoPrintPrinterSafetyCheckClient);
+ return OctoPrintPrinterSafetyCheckClient;
+});
diff --git a/src/octoprint/plugins/printer_safety_check/static/js/printer_safety_check.js b/src/octoprint/plugins/printer_safety_check/static/js/printer_safety_check.js
index c69bf8eb6..34e75aa97 100644
--- a/src/octoprint/plugins/printer_safety_check/static/js/printer_safety_check.js
+++ b/src/octoprint/plugins/printer_safety_check/static/js/printer_safety_check.js
@@ -1,22 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintPrinterSafetyCheckClient = function(base) {
- this.base = base;
- };
-
- OctoPrintPrinterSafetyCheckClient.prototype.get = function(opts) {
- return this.base.get(this.base.getSimpleApiUrl("printer_safety_check"), opts);
- };
-
- OctoPrintClient.registerPluginComponent("printer_safety_check", OctoPrintPrinterSafetyCheckClient);
- return OctoPrintPrinterSafetyCheckClient;
-});
-
$(function() {
function PrinterSafetyCheckViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py
index 2166d293b..bd13f2a3d 100644
--- a/src/octoprint/plugins/softwareupdate/__init__.py
+++ b/src/octoprint/plugins/softwareupdate/__init__.py
@@ -560,6 +560,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
return dict(
css=["css/softwareupdate.css"],
js=["js/softwareupdate.js"],
+ clientjs=["clientjs/softwareupdate.js"],
less=["less/softwareupdate.less"]
)
diff --git a/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js
new file mode 100644
index 000000000..932dcf8ce
--- /dev/null
+++ b/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js
@@ -0,0 +1,84 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintSoftwareUpdateClient = function(base) {
+ this.base = base;
+
+ var url = this.base.getBlueprintUrl("softwareupdate");
+ this.checkUrl = url + "check";
+ this.updateUrl = url + "update";
+ };
+
+ OctoPrintSoftwareUpdateClient.prototype.checkEntries = function(entries, force, opts) {
+ if (arguments.length == 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ entries = params.entries;
+ force = params.force;
+ opts = params.opts;
+ }
+
+ entries = entries || [];
+ if (typeof entries == "string") {
+ entries = [entries];
+ }
+
+ var data = {};
+ if (!!force) {
+ data.force = true;
+ }
+ if (entries && entries.length) {
+ data.check = entries.join(",");
+ }
+ return this.base.getWithQuery(this.checkUrl, data, opts);
+ };
+
+ OctoPrintSoftwareUpdateClient.prototype.check = function(force, opts) {
+ if (arguments.length === 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ force = params.force;
+ opts = params.opts;
+ }
+
+ return this.checkEntries({entries: [], force: force, opts: opts});
+ };
+
+ OctoPrintSoftwareUpdateClient.prototype.update = function(targets, force, opts) {
+ if (arguments.length === 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ targets = params.targets;
+ force = params.force;
+ opts = params.opts;
+ }
+
+ targets = targets || [];
+ if (typeof targets === "string") {
+ targets = [targets];
+ }
+
+ var data = {
+ targets: targets,
+ force: !!force
+ };
+ return this.base.postJson(this.updateUrl, data, opts);
+ };
+
+ OctoPrintSoftwareUpdateClient.prototype.updateAll = function(force, opts) {
+ if (arguments.length === 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ force = params.force;
+ opts = params.opts;
+ }
+
+ var data = {
+ force: !!force
+ };
+ return this.base.postJson(this.updateUrl, data, opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("softwareupdate", OctoPrintSoftwareUpdateClient);
+ return OctoPrintSoftwareUpdateClient;
+});
diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
index d0484a5b8..fbe341dae 100644
--- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
+++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
@@ -1,88 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintSoftwareUpdateClient = function(base) {
- this.base = base;
-
- var url = this.base.getBlueprintUrl("softwareupdate");
- this.checkUrl = url + "check";
- this.updateUrl = url + "update";
- };
-
- OctoPrintSoftwareUpdateClient.prototype.checkEntries = function(entries, force, opts) {
- if (arguments.length == 1 && _.isObject(arguments[0])) {
- var params = arguments[0];
- entries = params.entries;
- force = params.force;
- opts = params.opts;
- }
-
- entries = entries || [];
- if (typeof entries == "string") {
- entries = [entries];
- }
-
- var data = {};
- if (!!force) {
- data.force = true;
- }
- if (entries && entries.length) {
- data.check = entries.join(",");
- }
- return this.base.getWithQuery(this.checkUrl, data, opts);
- };
-
- OctoPrintSoftwareUpdateClient.prototype.check = function(force, opts) {
- if (arguments.length === 1 && _.isObject(arguments[0])) {
- var params = arguments[0];
- force = params.force;
- opts = params.opts;
- }
-
- return this.checkEntries({entries: [], force: force, opts: opts});
- };
-
- OctoPrintSoftwareUpdateClient.prototype.update = function(targets, force, opts) {
- if (arguments.length === 1 && _.isObject(arguments[0])) {
- var params = arguments[0];
- targets = params.targets;
- force = params.force;
- opts = params.opts;
- }
-
- targets = targets || [];
- if (typeof targets === "string") {
- targets = [targets];
- }
-
- var data = {
- targets: targets,
- force: !!force
- };
- return this.base.postJson(this.updateUrl, data, opts);
- };
-
- OctoPrintSoftwareUpdateClient.prototype.updateAll = function(force, opts) {
- if (arguments.length === 1 && _.isObject(arguments[0])) {
- var params = arguments[0];
- force = params.force;
- opts = params.opts;
- }
-
- var data = {
- force: !!force
- };
- return this.base.postJson(this.updateUrl, data, opts);
- };
-
- OctoPrintClient.registerPluginComponent("softwareupdate", OctoPrintSoftwareUpdateClient);
- return OctoPrintSoftwareUpdateClient;
-});
-
$(function() {
function SoftwareUpdateViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py
index 3c3ccb5b5..b8432b43d 100644
--- a/src/octoprint/server/__init__.py
+++ b/src/octoprint/server/__init__.py
@@ -1288,25 +1288,6 @@ class Server(object):
"js/lib/loglevel.min.js",
"js/lib/sockjs.js"
]
- js_client = [
- "js/app/client/base.js",
- "js/app/client/socket.js",
- "js/app/client/browser.js",
- "js/app/client/connection.js",
- "js/app/client/control.js",
- "js/app/client/files.js",
- "js/app/client/job.js",
- "js/app/client/languages.js",
- "js/app/client/printer.js",
- "js/app/client/printerprofiles.js",
- "js/app/client/settings.js",
- "js/app/client/slicing.js",
- "js/app/client/system.js",
- "js/app/client/timelapse.js",
- "js/app/client/users.js",
- "js/app/client/util.js",
- "js/app/client/wizard.js"
- ]
css_libs = [
"css/bootstrap.min.css",
@@ -1359,13 +1340,15 @@ class Server(object):
js_plugins = js_bundles_for_plugins(dynamic_plugin_assets["external"]["js"],
filters="js_delimiter_bundler")
+ clientjs_core = dynamic_core_assets["clientjs"] + \
+ all_assets_for_plugins(dynamic_plugin_assets["bundled"]["clientjs"])
+ clientjs_plugins = js_bundles_for_plugins(dynamic_plugin_assets["external"]["clientjs"],
+ filters="js_delimiter_bundler")
+
js_libs_bundle = Bundle(*js_libs,
output="webassets/packed_libs.js",
filters=",".join(js_filters))
- js_client_bundle = Bundle(*js_client,
- output="webassets/packed_client.js",
- filters=",".join(js_filters))
js_core_bundle = Bundle(*js_core,
output="webassets/packed_core.js",
filters=",".join(js_filters))
@@ -1381,6 +1364,21 @@ class Server(object):
output="webassets/packed_app.js",
filters=",".join(js_filters))
+ js_client_core_bundle = Bundle(*clientjs_core,
+ output="webassets/packed_client_core.js",
+ filters=",".join(js_filters))
+
+ if len(clientjs_plugins) == 0:
+ js_client_plugins_bundle = Bundle(*[])
+ else:
+ js_client_plugins_bundle = Bundle(*clientjs_plugins.values(),
+ output="webassets/packed_client_plugins.js",
+ filters=",".join(js_plugin_filters))
+
+ js_client_bundle = Bundle(js_client_core_bundle, js_client_plugins_bundle,
+ output="webassets/packed_client.js",
+ filters=",".join(js_filters))
+
# -- CSS -------------------------------------------------------------------------------------------------------
css_filters = ["cssrewrite"]
@@ -1440,6 +1438,11 @@ class Server(object):
# -- asset registration ----------------------------------------------------------------------------------------
assets.register("js_libs", js_libs_bundle)
+ assets.register("js_client_core", js_client_core_bundle)
+ for plugin, bundle in clientjs_plugins.items():
+ # register our collected clientjs plugin bundles so that they are bound to the environment
+ assets.register("js_client_plugin_{}".format(plugin), bundle)
+ assets.register("js_client_plugins", js_client_plugins_bundle)
assets.register("js_client", js_client_bundle)
assets.register("js_core", js_core_bundle)
for plugin, bundle in js_plugins.items():
diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py
index 8cca9c541..28eaa589f 100644
--- a/src/octoprint/server/util/flask.py
+++ b/src/octoprint/server/util/flask.py
@@ -1335,6 +1335,7 @@ class SettingsCheckUpdater(webassets.updater.BaseUpdater):
def collect_core_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
assets = dict(
js=[],
+ clientjs=[],
css=[],
less=[]
)
@@ -1376,6 +1377,26 @@ def collect_core_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
'gcodeviewer/js/renderer.js'
]
+ assets["clientjs"] = [
+ "js/app/client/base.js",
+ "js/app/client/socket.js",
+ "js/app/client/browser.js",
+ "js/app/client/connection.js",
+ "js/app/client/control.js",
+ "js/app/client/files.js",
+ "js/app/client/job.js",
+ "js/app/client/languages.js",
+ "js/app/client/printer.js",
+ "js/app/client/printerprofiles.js",
+ "js/app/client/settings.js",
+ "js/app/client/slicing.js",
+ "js/app/client/system.js",
+ "js/app/client/timelapse.js",
+ "js/app/client/users.js",
+ "js/app/client/util.js",
+ "js/app/client/wizard.js"
+ ]
+
if preferred_stylesheet == "less":
assets["less"].append('less/octoprint.less')
elif preferred_stylesheet == "css":
@@ -1390,9 +1411,11 @@ def collect_plugin_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
supported_stylesheets = ("css", "less")
assets = dict(bundled=dict(js=DefaultOrderedDict(list),
+ clientjs=DefaultOrderedDict(list),
css=DefaultOrderedDict(list),
less=DefaultOrderedDict(list)),
external=dict(js=DefaultOrderedDict(list),
+ clientjs=DefaultOrderedDict(list),
css=DefaultOrderedDict(list),
less=DefaultOrderedDict(list)))
@@ -1422,6 +1445,12 @@ def collect_plugin_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
continue
assets[asset_key]["js"][name].append('plugin/{name}/{asset}'.format(**locals()))
+ if "clientjs" in all_assets:
+ for asset in all_assets["clientjs"]:
+ if not asset_exists("clientjs", asset):
+ continue
+ assets[asset_key]["clientjs"][name].append("plugin/{name}/{asset}".format(**locals()))
+
if preferred_stylesheet in all_assets:
for asset in all_assets[preferred_stylesheet]:
if not asset_exists(preferred_stylesheet, asset):
From 61d037f188e7ea70e3b6e36936a53c75c019d2bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Tue, 28 Aug 2018 22:02:40 +0200
Subject: [PATCH 007/183] Clientlib: support operation without api key
---
src/octoprint/static/js/app/client/base.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/octoprint/static/js/app/client/base.js b/src/octoprint/static/js/app/client/base.js
index 2eb51d4d9..f8e6b3ae0 100644
--- a/src/octoprint/static/js/app/client/base.js
+++ b/src/octoprint/static/js/app/client/base.js
@@ -111,7 +111,9 @@
additional = additional || {};
var headers = $.extend({}, additional);
- headers["X-Api-Key"] = this.options.apikey;
+ if (this.options.apikey) {
+ headers["X-Api-Key"] = this.options.apikey;
+ }
if (this.options.locale !== undefined) {
headers["X-Locale"] = this.options.locale;
From 2343caea30071e42b51b6843fd95f0001f662795 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Tue, 28 Aug 2018 22:04:34 +0200
Subject: [PATCH 008/183] New options for confirmation dialog
* oncancel: callback to call when cancel button is pressed
* noclose: don't allow dismissing/closing the dialog without having
chosen to proceed or cancel
---
src/octoprint/static/js/app/helpers.js | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js
index 1eb161d05..7df9e46af 100644
--- a/src/octoprint/static/js/app/helpers.js
+++ b/src/octoprint/static/js/app/helpers.js
@@ -708,11 +708,19 @@ function showConfirmationDialog(msg, onacknowledge, options) {
var proceed = options.proceed || gettext("Proceed");
var proceedClass = options.proceedClass || "danger";
var onproceed = options.onproceed || undefined;
+ var oncancel = options.oncancel || undefined;
var onclose = options.onclose || undefined;
var dialogClass = options.dialogClass || "";
var nofade = options.nofade || false;
+ var noclose = options.noclose || false;
+
+ var modalHeader;
+ if (noclose) {
+ modalHeader = $('' + title + ' ');
+ } else {
+ modalHeader = $('× ' + title + ' ');
+ }
- var modalHeader = $('× ' + title + ' ');
var modalBody;
if (html) {
modalBody = $(html);
@@ -740,7 +748,13 @@ function showConfirmationDialog(msg, onacknowledge, options) {
onclose(event);
}
});
- modal.modal("show");
+
+ var modalOptions = {};
+ if (noclose) {
+ modalOptions.backdrop = "static";
+ modalOptions.keyboard = false;
+ }
+ modal.modal(modalOptions);
proceedButton.click(function(e) {
e.preventDefault();
@@ -749,6 +763,11 @@ function showConfirmationDialog(msg, onacknowledge, options) {
}
modal.modal("hide");
});
+ cancelButton.click(function(e) {
+ if (oncancel && _.isFunction(oncancel)) {
+ oncancel(e);
+ }
+ });
return modal;
}
From b0028cd3fb64ed68c73e386b82566d7c39bf90c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Tue, 28 Aug 2018 22:05:28 +0200
Subject: [PATCH 009/183] AppAuth: workflow fully implemented & client lib
---
src/octoprint/plugins/appauth/__init__.py | 37 +++++----
.../appauth/static/clientjs/appauth.js | 83 +++++++++++++++++++
.../plugins/appauth/static/js/appauth.js | 41 ++-------
3 files changed, 109 insertions(+), 52 deletions(-)
create mode 100644 src/octoprint/plugins/appauth/static/clientjs/appauth.js
diff --git a/src/octoprint/plugins/appauth/__init__.py b/src/octoprint/plugins/appauth/__init__.py
index 08d0bcf6b..398f2005f 100644
--- a/src/octoprint/plugins/appauth/__init__.py
+++ b/src/octoprint/plugins/appauth/__init__.py
@@ -31,15 +31,14 @@ class PendingDecision(object):
class ReadyDecision(object):
- def __init__(self, app_id, app_token, user_id, api_key):
+ def __init__(self, app_id, app_token, user_id):
self.app_id = app_id
self.app_token = app_token
self.user_id = user_id
- self.api_key = api_key
@classmethod
- def for_pending(cls, pending, api_key):
- return cls(pending.app_id, pending.app_token, pending.user_id, api_key)
+ def for_pending(cls, pending, user_id):
+ return cls(pending.app_id, pending.app_token, user_id)
class ActiveKey(object):
@@ -70,7 +69,8 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
##-- AssetPlugin hooks
def get_assets(self):
- return dict(js=["js/appauth.js"])
+ return dict(js=["js/appauth.js"],
+ clientjs=["clientjs/appauth.js"])
##~~ BlueprintPlugin mixin
@@ -101,10 +101,12 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
@no_firstrun_access
def handle_decision_poll(self, app_token):
if self._is_pending(app_token):
- return flask.make_response("Awaiting decision", 202)
+ response = flask.jsonify(message="Awaiting decision")
+ response.status_code = 202
+ return response
result = self._get_decision(app_token)
- if result is not None:
+ if result:
return flask.jsonify(api_key=result)
return flask.abort(404)
@@ -159,11 +161,7 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
if not app_name:
return flask.abort(400)
- api_key = self._generate_key()
- try:
- self._add_api_key(user_id, app_name.trim(), api_key)
- except AppAlreadyExists:
- return flask.abort(409)
+ self._add_api_key(user_id, app_name.trim())
return NO_CONTENT
@@ -210,7 +208,7 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
if decision:
with self._ready_lock:
- self._ready_decisions.append(ReadyDecision.for_pending(pending, self._generate_key()))
+ self._ready_decisions.append(ReadyDecision.for_pending(pending, user_id))
with self._pending_lock:
self._pending_decisions = filter(lambda x: x.user_token != user_token, self._pending_decisions)
@@ -226,20 +224,23 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
else:
return False # not found
- self._add_api_key(decision.user_id, decision.app_id, decision.api_key)
+ api_key = self._add_api_key(decision.user_id, decision.app_id)
with self._ready_lock:
self._ready_decisions = filter(lambda x: x.app_token != app_token, self._ready_decisions)
- return decision.api_key
+ return api_key
- def _add_api_key(self, user_id, app_name, api_key):
+ def _add_api_key(self, user_id, app_name):
with self._keys_lock:
# TODO: persist to disk
for key in self._keys[user_id]:
if key.app_id.lower() == app_name.lower():
- raise AppAlreadyExists("app {} does already exist".format(app_name))
- self._keys[user_id].append(ActiveKey(app_name, api_key))
+ return key.api_key
+
+ key = ActiveKey(app_name, self._generate_key())
+ self._keys[user_id].append(key)
+ return key.api_key
def _delete_api_key(self, user_id, api_key):
with self._keys_lock:
diff --git a/src/octoprint/plugins/appauth/static/clientjs/appauth.js b/src/octoprint/plugins/appauth/static/clientjs/appauth.js
new file mode 100644
index 000000000..57800af43
--- /dev/null
+++ b/src/octoprint/plugins/appauth/static/clientjs/appauth.js
@@ -0,0 +1,83 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintAppAuthClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintAppAuthClient.prototype.getKeys = function(opts) {
+ return this.base.simpleApiGet("appauth", opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.generateKey = function(app, opts) {
+ return this.base.simpleApiCommand("appauth", "generate", {"app": app}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.revokeKey = function(key, opts) {
+ return this.base.simpleApiCommand("appauth", "revoke", {"key": key}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.decide = function(token, decision, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appauth") + "decision/" + token, {decision: !!decision}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.request = function(app, opts) {
+ return this.requestForUser(app, undefined, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.requestForUser = function(app, user, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appauth") + "request", {app: app, user: user}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.checkDecision = function(token, opts) {
+ return this.base.get(this.base.getBlueprintUrl("appauth") + "request/" + token, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.authenticate = function(app, user) {
+ var deferred = $.Deferred();
+ var client = this;
+
+ client.requestForUser(app, user)
+ .done(function(response) {
+ var token = response.app_token;
+ if (!token) {
+ // no token received, something went wrong
+ deferred.reject();
+ return;
+ }
+
+ var interval = 1000;
+ var poll = function() {
+ client.checkDecision(token)
+ .done(function(response) {
+ if (response.api_key) {
+ // got a decision, resolve the promise
+ deferred.resolve(response.api_key);
+ } else {
+ // no decision yet, poll a bit more
+ deferred.notify();
+ window.setTimeout(poll, interval);
+ }
+ })
+ .fail(function() {
+ // something went wrong
+ deferred.reject();
+ });
+ };
+ window.setTimeout(poll, interval);
+ })
+ .fail(function() {
+ // something went wrong
+ deferred.reject();
+ });
+
+ return deferred.promise();
+ };
+
+ OctoPrintClient.registerPluginComponent("appauth", OctoPrintAppAuthClient);
+ return OctoPrintAppAuthClient;
+});
diff --git a/src/octoprint/plugins/appauth/static/js/appauth.js b/src/octoprint/plugins/appauth/static/js/appauth.js
index 74ec1e6e1..1cc353935 100644
--- a/src/octoprint/plugins/appauth/static/js/appauth.js
+++ b/src/octoprint/plugins/appauth/static/js/appauth.js
@@ -1,34 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintAppAuthClient = function(base) {
- this.base = base;
- };
-
- OctoPrintAppAuthClient.prototype.getKeys = function(opts) {
- return this.base.simpleApiGet("appauth", opts);
- };
-
- OctoPrintAppAuthClient.prototype.generateKey = function(app, opts) {
- return this.base.simpleApiCommand("appauth", "generate", {"app": app}, opts);
- };
-
- OctoPrintAppAuthClient.prototype.revokeKey = function(key, opts) {
- return this.base.simpleApiCommand("appauth", "revoke", {"key": key}, opts);
- };
-
- OctoPrintAppAuthClient.prototype.decide = function(token, decision, opts) {
- return this.base.postJson(this.base.getBlueprintUrl("appauth") + "decision/" + token, {decision: !!decision}, opts);
- };
-
- OctoPrintClient.registerPluginComponent("appauth", OctoPrintAppAuthClient);
- return OctoPrintAppAuthClient;
-});
-
$(function() {
function AppAuthViewModel(parameters) {
var self = this;
@@ -90,23 +59,27 @@ $(function() {
};
self.promptForAccess = function(app, token) {
- var message = gettext("\"%(app)s\" has requested access to control OctoPrint through the API. Do you want to allow access to this application with your user account?");
+ var message = gettext("\"%(app)s \" has requested access to control OctoPrint through the API.");
message = _.sprintf(message, {app: app});
-
+ message = "" + message + "
" + gettext("Do you want to allow access to this application with your user account?") + "
";
return new PNotify({
title: gettext("Access Request"),
text: message,
+ hide: false,
+ icon: "fa fa-key",
confirm: {
confirm: true,
buttons: [{
text: gettext("Allow"),
click: function(notice) {
self.allowApp(token);
+ notice.remove();
}
}, {
text: gettext("Deny"),
click: function(notice) {
self.denyApp(token);
+ notice.remove();
}
}]
},
@@ -141,7 +114,7 @@ $(function() {
return;
}
- if (self.pending[token] === undefined) {
+ if (self.pending[token] !== undefined) {
return;
}
From 2f1d71a98ccb77211be549194562426bd6156c26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 31 Aug 2018 20:22:40 +0200
Subject: [PATCH 010/183] appauth -> appkeys
---
.../templates/appauth_usersettings.jinja2 | 42 ----------------
.../plugins/{appauth => appkeys}/__init__.py | 22 ++++++---
.../static/clientjs/appkeys.js} | 34 ++++++-------
.../plugins/appkeys/static/css/appkeys.css | 1 +
.../static/js/appkeys.js} | 20 ++++----
.../plugins/appkeys/static/less/appkeys.less | 12 +++++
.../templates/appkeys_usersettings.jinja2 | 49 +++++++++++++++++++
7 files changed, 104 insertions(+), 76 deletions(-)
delete mode 100644 src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
rename src/octoprint/plugins/{appauth => appkeys}/__init__.py (92%)
rename src/octoprint/plugins/{appauth/static/clientjs/appauth.js => appkeys/static/clientjs/appkeys.js} (66%)
create mode 100644 src/octoprint/plugins/appkeys/static/css/appkeys.css
rename src/octoprint/plugins/{appauth/static/js/appauth.js => appkeys/static/js/appkeys.js} (89%)
create mode 100644 src/octoprint/plugins/appkeys/static/less/appkeys.less
create mode 100644 src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
diff --git a/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2 b/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
deleted file mode 100644
index aeb2f9e67..000000000
--- a/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- {{ _('Application') }}
- {{ _('Action') }}
-
-
-
-
- {{ _('API Key') }}:
-
-
-
-
-
-
-
-
-
diff --git a/src/octoprint/plugins/appauth/__init__.py b/src/octoprint/plugins/appkeys/__init__.py
similarity index 92%
rename from src/octoprint/plugins/appauth/__init__.py
rename to src/octoprint/plugins/appkeys/__init__.py
index 398f2005f..27c261b69 100644
--- a/src/octoprint/plugins/appauth/__init__.py
+++ b/src/octoprint/plugins/appkeys/__init__.py
@@ -6,6 +6,7 @@ import threading
import os
from binascii import hexlify
from collections import defaultdict
+from flask_babel import gettext
import octoprint.plugin
from octoprint.settings import valid_boolean_trues
@@ -51,7 +52,7 @@ class ActiveKey(object):
api_key=self.api_key)
-class AppAuthPlugin(octoprint.plugin.AssetPlugin,
+class AppKeysPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.BlueprintPlugin,
octoprint.plugin.SimpleApiPlugin,
octoprint.plugin.TemplatePlugin):
@@ -66,11 +67,18 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
self._keys = defaultdict(list)
self._keys_lock = threading.RLock()
- ##-- AssetPlugin hooks
+ ##~~ TemplatePlugin
+
+ def get_template_configs(self):
+ return [dict(type="usersettings", name=gettext("Application Keys"), custom_bindings=False)]
+
+ ##~~ AssetPlugin
def get_assets(self):
- return dict(js=["js/appauth.js"],
- clientjs=["clientjs/appauth.js"])
+ return dict(js=["js/appkeys.js"],
+ clientjs=["clientjs/appkeys.js"],
+ less=["less/appkeys.less"],
+ css=["css/appkeys.css"])
##~~ BlueprintPlugin mixin
@@ -161,7 +169,7 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
if not app_name:
return flask.abort(400)
- self._add_api_key(user_id, app_name.trim())
+ self._add_api_key(user_id, app_name.strip())
return NO_CONTENT
@@ -261,10 +269,10 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
def _generate_key(self):
return hexlify(os.urandom(16))
-__plugin_name__ = "AppAuth Plugin"
+__plugin_name__ = "Application Keys Plugin"
__plugin_description__ = "TODO"
__plugin_author__ = "Gina Häußge, Aldo Hoeben"
-__plugin_implementation__ = AppAuthPlugin()
+__plugin_implementation__ = AppKeysPlugin()
__plugin_hooks__ = {
"octoprint.accesscontrol.keyvalidator": __plugin_implementation__.validate_api_key
}
diff --git a/src/octoprint/plugins/appauth/static/clientjs/appauth.js b/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
similarity index 66%
rename from src/octoprint/plugins/appauth/static/clientjs/appauth.js
rename to src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
index 57800af43..1e70f4b89 100644
--- a/src/octoprint/plugins/appauth/static/clientjs/appauth.js
+++ b/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
@@ -5,39 +5,39 @@
factory(global.OctoPrintClient);
}
})(this, function(OctoPrintClient) {
- var OctoPrintAppAuthClient = function(base) {
+ var OctoPrintAppKeysClient = function(base) {
this.base = base;
};
- OctoPrintAppAuthClient.prototype.getKeys = function(opts) {
- return this.base.simpleApiGet("appauth", opts);
+ OctoPrintAppKeysClient.prototype.getKeys = function(opts) {
+ return this.base.simpleApiGet("appkeys", opts);
};
- OctoPrintAppAuthClient.prototype.generateKey = function(app, opts) {
- return this.base.simpleApiCommand("appauth", "generate", {"app": app}, opts);
+ OctoPrintAppKeysClient.prototype.generateKey = function(app, opts) {
+ return this.base.simpleApiCommand("appkeys", "generate", {"app": app}, opts);
};
- OctoPrintAppAuthClient.prototype.revokeKey = function(key, opts) {
- return this.base.simpleApiCommand("appauth", "revoke", {"key": key}, opts);
+ OctoPrintAppKeysClient.prototype.revokeKey = function(key, opts) {
+ return this.base.simpleApiCommand("appkeys", "revoke", {"key": key}, opts);
};
- OctoPrintAppAuthClient.prototype.decide = function(token, decision, opts) {
- return this.base.postJson(this.base.getBlueprintUrl("appauth") + "decision/" + token, {decision: !!decision}, opts);
+ OctoPrintAppKeysClient.prototype.decide = function(token, decision, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appkeys") + "decision/" + token, {decision: !!decision}, opts);
};
- OctoPrintAppAuthClient.prototype.request = function(app, opts) {
+ OctoPrintAppKeysClient.prototype.request = function(app, opts) {
return this.requestForUser(app, undefined, opts);
};
- OctoPrintAppAuthClient.prototype.requestForUser = function(app, user, opts) {
- return this.base.postJson(this.base.getBlueprintUrl("appauth") + "request", {app: app, user: user}, opts);
+ OctoPrintAppKeysClient.prototype.requestForUser = function(app, user, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appkeys") + "request", {app: app, user: user}, opts);
};
- OctoPrintAppAuthClient.prototype.checkDecision = function(token, opts) {
- return this.base.get(this.base.getBlueprintUrl("appauth") + "request/" + token, opts);
+ OctoPrintAppKeysClient.prototype.checkDecision = function(token, opts) {
+ return this.base.get(this.base.getBlueprintUrl("appkeys") + "request/" + token, opts);
};
- OctoPrintAppAuthClient.prototype.authenticate = function(app, user) {
+ OctoPrintAppKeysClient.prototype.authenticate = function(app, user) {
var deferred = $.Deferred();
var client = this;
@@ -78,6 +78,6 @@
return deferred.promise();
};
- OctoPrintClient.registerPluginComponent("appauth", OctoPrintAppAuthClient);
- return OctoPrintAppAuthClient;
+ OctoPrintClient.registerPluginComponent("appkeys", OctoPrintAppKeysClient);
+ return OctoPrintAppKeysClient;
});
diff --git a/src/octoprint/plugins/appkeys/static/css/appkeys.css b/src/octoprint/plugins/appkeys/static/css/appkeys.css
new file mode 100644
index 000000000..20673bafa
--- /dev/null
+++ b/src/octoprint/plugins/appkeys/static/css/appkeys.css
@@ -0,0 +1 @@
+#settings_plugin_appauth_keys_table .settings_plugin_appauth_keys_actions{width:75px;text-align:center}#settings_plugin_appauth_keys_table .settings_plugin_appauth_keys_actions a{color:#000}
\ No newline at end of file
diff --git a/src/octoprint/plugins/appauth/static/js/appauth.js b/src/octoprint/plugins/appkeys/static/js/appkeys.js
similarity index 89%
rename from src/octoprint/plugins/appauth/static/js/appauth.js
rename to src/octoprint/plugins/appkeys/static/js/appkeys.js
index 1cc353935..015493f8f 100644
--- a/src/octoprint/plugins/appauth/static/js/appauth.js
+++ b/src/octoprint/plugins/appkeys/static/js/appkeys.js
@@ -1,10 +1,10 @@
$(function() {
- function AppAuthViewModel(parameters) {
+ function AppKeysViewModel(parameters) {
var self = this;
self.loginState = parameters[0];
self.keys = new ItemListHelper(
- "plugin.appauth.keys",
+ "plugin.appkeys.keys",
{
"app": function (a, b) {
// sorts descending
@@ -26,7 +26,7 @@ $(function() {
self.editorApp = ko.observable();
self.requestData = function() {
- OctoPrint.plugins.appauth.getKeys()
+ OctoPrint.plugins.appkeys.getKeys()
.done(self.fromResponse);
};
@@ -39,22 +39,22 @@ $(function() {
};
self.generateKey = function() {
- return OctoPrint.plugins.appauth.generateKey(self.editorApp())
+ return OctoPrint.plugins.appkeys.generateKey(self.editorApp())
.done(self.requestData);
};
self.revokeKey = function(key) {
- return OctoPrint.plugins.appauth.revokeKey(key)
+ return OctoPrint.plugins.appkeys.revokeKey(key)
.done(self.requestData);
};
self.allowApp = function(token) {
- return OctoPrint.plugins.appauth.decide(token, true)
+ return OctoPrint.plugins.appkeys.decide(token, true)
.done(self.requestData);
};
self.denyApp = function(token) {
- return OctoPrint.plugins.appauth.decide(token, false)
+ return OctoPrint.plugins.appkeys.decide(token, false)
.done(self.requestData);
};
@@ -99,7 +99,7 @@ $(function() {
};
self.onDataUpdaterPluginMessage = function(plugin, data) {
- if (plugin !== "appauth") {
+ if (plugin !== "appkeys") {
return;
}
@@ -135,8 +135,8 @@ $(function() {
}
OCTOPRINT_VIEWMODELS.push([
- AppAuthViewModel,
+ AppKeysViewModel,
["loginStateViewModel"],
- ["#usersettings_plugin_appauth"]
+ ["#usersettings_plugin_appkeys"]
]);
});
diff --git a/src/octoprint/plugins/appkeys/static/less/appkeys.less b/src/octoprint/plugins/appkeys/static/less/appkeys.less
new file mode 100644
index 000000000..1b871993f
--- /dev/null
+++ b/src/octoprint/plugins/appkeys/static/less/appkeys.less
@@ -0,0 +1,12 @@
+#settings_plugin_appauth_keys_table {
+ .settings_plugin_appauth_keys_app {
+ }
+ .settings_plugin_appauth_keys_actions {
+ width: 75px;
+ text-align: center;
+
+ a {
+ color: black;
+ }
+ }
+}
diff --git a/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2 b/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
new file mode 100644
index 000000000..0eae9334d
--- /dev/null
+++ b/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
@@ -0,0 +1,49 @@
+{{ _('Registered application keys') }}
+
+
+
{{ _('There are no application keys registered yet.') }}
+
+
+
+
+
+ {{ _('Application identifier') }}
+ {{ _('Action') }}
+
+
+
+
+ {{ _('API Key') }}:
+
+
+
+
+
+
+
+{{ _('Manually generate an application key') }}
+
+
From 224674f27e26d41b087bc7824dff221a3c976674 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 31 Aug 2018 20:35:16 +0200
Subject: [PATCH 011/183] Appkeys: fix template config
---
src/octoprint/plugins/appkeys/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py
index 27c261b69..91b0ca960 100644
--- a/src/octoprint/plugins/appkeys/__init__.py
+++ b/src/octoprint/plugins/appkeys/__init__.py
@@ -70,7 +70,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
##~~ TemplatePlugin
def get_template_configs(self):
- return [dict(type="usersettings", name=gettext("Application Keys"), custom_bindings=False)]
+ return [dict(type="usersettings", name=gettext("Application Keys"))]
##~~ AssetPlugin
From 2ca63febee440cb3294f3f4c57c8f308ee595504 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 31 Aug 2018 20:45:16 +0200
Subject: [PATCH 012/183] Appkeys: allow fetching of all keys
Also added TODO list ;)
---
src/octoprint/plugins/appkeys/__init__.py | 35 ++++++++++++++++---
.../appkeys/static/clientjs/appkeys.js | 4 +++
2 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py
index 91b0ca960..2666047b9 100644
--- a/src/octoprint/plugins/appkeys/__init__.py
+++ b/src/octoprint/plugins/appkeys/__init__.py
@@ -11,7 +11,18 @@ from flask_babel import gettext
import octoprint.plugin
from octoprint.settings import valid_boolean_trues
from octoprint.server.util.flask import restricted_access, no_firstrun_access
-from octoprint.server import NO_CONTENT, current_user, user_permission
+from octoprint.server import NO_CONTENT, current_user, admin_permission
+
+
+"""
+TODO:
+ * add key persistence
+ * add central management settings panel for *all* user's keys
+ * bulk delete: delete all, all on page, all by user?
+ * write documentation
+ * API docs
+ * JS client docs
+"""
class AppAlreadyExists(Exception):
@@ -43,13 +54,15 @@ class ReadyDecision(object):
class ActiveKey(object):
- def __init__(self, app_id, api_key):
+ def __init__(self, app_id, api_key, user_id):
self.app_id = app_id
self.api_key = api_key
+ self.user_id = user_id
def external(self):
return dict(app_id=self.app_id,
- api_key=self.api_key)
+ api_key=self.api_key,
+ user_id=self.user_id)
class AppKeysPlugin(octoprint.plugin.AssetPlugin,
@@ -148,7 +161,12 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
if not user_id:
return flask.abort(403)
- return flask.jsonify(keys=map(lambda x: x.external(), self._api_keys_for_user(user_id)),
+ if request.values.get("all") in valid_boolean_trues and admin_permission.can():
+ keys = self._all_api_keys()
+ else:
+ keys = self._api_keys_for_user(user_id)
+
+ return flask.jsonify(keys=map(lambda x: x.external(), keys),
pending=dict((x.user_token, x.external()) for x in self._get_pending(user_id)))
def on_api_command(self, command, data):
@@ -246,7 +264,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
if key.app_id.lower() == app_name.lower():
return key.api_key
- key = ActiveKey(app_name, self._generate_key())
+ key = ActiveKey(app_name, self._generate_key(), user_id)
self._keys[user_id].append(key)
return key.api_key
@@ -266,6 +284,13 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
with self._keys_lock:
return self._keys.get(user_id, [])
+ def _all_api_keys(self):
+ with self._keys_lock:
+ result = []
+ for user_id, keys in self._keys.items():
+ result += keys
+ return result
+
def _generate_key(self):
return hexlify(os.urandom(16))
diff --git a/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js b/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
index 1e70f4b89..580ad1364 100644
--- a/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
+++ b/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
@@ -13,6 +13,10 @@
return this.base.simpleApiGet("appkeys", opts);
};
+ OctoPrintAppKeysClient.prototype.getAllKeys = function(opts) {
+ return this.base.get(OctoPrintClient.prototype.getSimpleApiUrl("appkeys") + "?all=true", opts);
+ };
+
OctoPrintAppKeysClient.prototype.generateKey = function(app, opts) {
return this.base.simpleApiCommand("appkeys", "generate", {"app": app}, opts);
};
From 4a36a3eed2b94e25da967630ce9b4e90eb495714 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Mon, 3 Sep 2018 18:38:36 +0200
Subject: [PATCH 013/183] Appkeys: Add key persistence
---
src/octoprint/plugins/appkeys/__init__.py | 54 ++++++++++++++++++++++-
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py
index 2666047b9..5f491db96 100644
--- a/src/octoprint/plugins/appkeys/__init__.py
+++ b/src/octoprint/plugins/appkeys/__init__.py
@@ -4,6 +4,9 @@ from __future__ import absolute_import
import flask
import threading
import os
+import yaml
+import codecs
+import time
from binascii import hexlify
from collections import defaultdict
from flask_babel import gettext
@@ -12,6 +15,7 @@ import octoprint.plugin
from octoprint.settings import valid_boolean_trues
from octoprint.server.util.flask import restricted_access, no_firstrun_access
from octoprint.server import NO_CONTENT, current_user, admin_permission
+from octoprint.util import atomic_write
"""
@@ -64,6 +68,14 @@ class ActiveKey(object):
api_key=self.api_key,
user_id=self.user_id)
+ def internal(self):
+ return dict(app_id=self.app_id,
+ api_key=self.api_key)
+
+ @classmethod
+ def for_internal(cls, internal, user_id):
+ return cls(internal["app_id"], internal["api_key"], user_id)
+
class AppKeysPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.BlueprintPlugin,
@@ -80,6 +92,12 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
self._keys = defaultdict(list)
self._keys_lock = threading.RLock()
+ self._key_path = None
+
+ def initialize(self):
+ self._key_path = os.path.join(self.get_plugin_data_folder(), "keys.yaml")
+ self._load_keys()
+
##~~ TemplatePlugin
def get_template_configs(self):
@@ -259,19 +277,19 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
def _add_api_key(self, user_id, app_name):
with self._keys_lock:
- # TODO: persist to disk
for key in self._keys[user_id]:
if key.app_id.lower() == app_name.lower():
return key.api_key
key = ActiveKey(app_name, self._generate_key(), user_id)
self._keys[user_id].append(key)
+ self._save_keys()
return key.api_key
def _delete_api_key(self, user_id, api_key):
with self._keys_lock:
- # TODO: persist to disk
self._keys[user_id] = filter(lambda x: x.api_key != api_key, self._keys[user_id])
+ self._save_keys()
def _user_for_api_key(self, api_key):
with self._keys_lock:
@@ -294,6 +312,38 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
def _generate_key(self):
return hexlify(os.urandom(16))
+ def _load_keys(self):
+ with self._keys_lock:
+ if not os.path.exists(self._key_path):
+ return
+
+ try:
+ with codecs.open(self._key_path, "rb", encoding="utf-8", errors="strict") as f:
+ persisted = yaml.safe_load(f)
+ except:
+ self._logger.exception("Could not load application keys from {}".format(self._key_path))
+ return
+
+ if not isinstance(persisted, dict):
+ return
+
+ keys = dict()
+ for user_id, persisted_keys in persisted.items():
+ keys[user_id] = [ActiveKey.for_internal(x, user_id) for x in persisted_keys]
+ self._keys = keys
+
+ def _save_keys(self):
+ with self._keys_lock:
+ to_persist = dict()
+ for user_id, keys in self._keys.items():
+ to_persist[user_id] = [x.internal() for x in keys]
+
+ try:
+ with atomic_write(self._key_path) as f:
+ yaml.safe_dump(to_persist, f)
+ except:
+ self._logger.exception("Could not write application keys to {}".format(self._key_path))
+
__plugin_name__ = "Application Keys Plugin"
__plugin_description__ = "TODO"
__plugin_author__ = "Gina Häußge, Aldo Hoeben"
From 4e3adcc3f3ca92005643d2d365f5195764d61d14 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 24 Aug 2018 11:58:56 +0200
Subject: [PATCH 014/183] Add no_firstrun_access decorator
---
src/octoprint/server/util/flask.py | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py
index 567291bbd..1befcb36b 100644
--- a/src/octoprint/server/util/flask.py
+++ b/src/octoprint/server/util/flask.py
@@ -1146,11 +1146,7 @@ def restricted_access(func):
"""
@functools.wraps(func)
def decorated_view(*args, **kwargs):
- # if OctoPrint hasn't been set up yet, abort
- if settings().getBoolean(["server", "firstRun"]) and settings().getBoolean(["accessControl", "enabled"]) and (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()):
- return flask.make_response("OctoPrint isn't setup yet", 403)
-
- return flask_login.login_required(func)(*args, **kwargs)
+ return flask_login.login_required(no_firstrun_access(func))(*args, **kwargs)
return decorated_view
@@ -1172,6 +1168,24 @@ def firstrun_only_access(func):
return decorated_view
+def no_firstrun_access(func):
+ """
+ If you decorate a view with this, it will ensure that first setup as been done for
+ OctoPrint's Access Control. Otherwise it
+ will cause a HTTP 403 status code to be returned by the decorated resource.
+ """
+
+ @functools.wraps(func)
+ def decorated_view(*args, **kwargs):
+ # if OctoPrint hasn't been set up yet, abort
+ if settings().getBoolean(["server", "firstRun"]) and settings().getBoolean(["accessControl", "enabled"]) and \
+ (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()):
+ return flask.make_response("OctoPrint isn't setup yet", 403)
+ return func(*args, **kwargs)
+
+ return decorated_view
+
+
class AppSessionManager(object):
VALIDITY_UNVERIFIED = 1 * 60 # 1 minute
From b428faacc8d30082f897c3905def0788b1345b9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 24 Aug 2018 11:59:23 +0200
Subject: [PATCH 015/183] Appauth plugin: WIP
---
src/octoprint/plugins/appauth/__init__.py | 269 ++++++++++++++++++
.../plugins/appauth/static/js/appauth.js | 169 +++++++++++
.../templates/appauth_usersettings.jinja2 | 42 +++
3 files changed, 480 insertions(+)
create mode 100644 src/octoprint/plugins/appauth/__init__.py
create mode 100644 src/octoprint/plugins/appauth/static/js/appauth.js
create mode 100644 src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
diff --git a/src/octoprint/plugins/appauth/__init__.py b/src/octoprint/plugins/appauth/__init__.py
new file mode 100644
index 000000000..08d0bcf6b
--- /dev/null
+++ b/src/octoprint/plugins/appauth/__init__.py
@@ -0,0 +1,269 @@
+# coding=utf-8
+from __future__ import absolute_import
+
+import flask
+import threading
+import os
+from binascii import hexlify
+from collections import defaultdict
+
+import octoprint.plugin
+from octoprint.settings import valid_boolean_trues
+from octoprint.server.util.flask import restricted_access, no_firstrun_access
+from octoprint.server import NO_CONTENT, current_user, user_permission
+
+
+class AppAlreadyExists(Exception):
+ pass
+
+
+class PendingDecision(object):
+ def __init__(self, app_id, app_token, user_id, user_token):
+ self.app_id = app_id
+ self.app_token = app_token
+ self.user_id = user_id
+ self.user_token = user_token
+
+ def external(self):
+ return dict(app_id=self.app_id,
+ user_id=self.user_id,
+ user_token=self.user_token)
+
+
+class ReadyDecision(object):
+ def __init__(self, app_id, app_token, user_id, api_key):
+ self.app_id = app_id
+ self.app_token = app_token
+ self.user_id = user_id
+ self.api_key = api_key
+
+ @classmethod
+ def for_pending(cls, pending, api_key):
+ return cls(pending.app_id, pending.app_token, pending.user_id, api_key)
+
+
+class ActiveKey(object):
+ def __init__(self, app_id, api_key):
+ self.app_id = app_id
+ self.api_key = api_key
+
+ def external(self):
+ return dict(app_id=self.app_id,
+ api_key=self.api_key)
+
+
+class AppAuthPlugin(octoprint.plugin.AssetPlugin,
+ octoprint.plugin.BlueprintPlugin,
+ octoprint.plugin.SimpleApiPlugin,
+ octoprint.plugin.TemplatePlugin):
+
+ def __init__(self):
+ self._pending_decisions = []
+ self._pending_lock = threading.RLock()
+
+ self._ready_decisions = []
+ self._ready_lock = threading.RLock()
+
+ self._keys = defaultdict(list)
+ self._keys_lock = threading.RLock()
+
+ ##-- AssetPlugin hooks
+
+ def get_assets(self):
+ return dict(js=["js/appauth.js"])
+
+ ##~~ BlueprintPlugin mixin
+
+ @octoprint.plugin.BlueprintPlugin.route("/request", methods=["POST"])
+ @no_firstrun_access
+ def handle_request(self):
+ data = flask.request.json
+ if not "app" in data:
+ return flask.make_response("No app name provided", 400)
+
+ app_name = data["app"]
+ user_id = None
+ if "user" in data:
+ user_id = data["user"]
+
+ app_token, user_token = self._add_pending_decision(app_name, user_id=user_id)
+
+ self._plugin_manager.send_plugin_message(self._identifier, dict(type="request_access",
+ app_name=app_name,
+ user_token=user_token,
+ user_id=user_id))
+ response = flask.jsonify(app_token=app_token)
+ response.status_code = 202
+ response.headers["Location"] = flask.url_for(".handle_decision_poll", app_token=app_token, _external=True)
+ return response
+
+ @octoprint.plugin.BlueprintPlugin.route("/request/")
+ @no_firstrun_access
+ def handle_decision_poll(self, app_token):
+ if self._is_pending(app_token):
+ return flask.make_response("Awaiting decision", 202)
+
+ result = self._get_decision(app_token)
+ if result is not None:
+ return flask.jsonify(api_key=result)
+
+ return flask.abort(404)
+
+ @octoprint.plugin.BlueprintPlugin.route("/decision/", methods=["POST"])
+ @restricted_access
+ def handle_decision(self, user_token):
+ data = flask.request.json
+ if not "decision" in data:
+ return flask.make_response("No decision provided", 400)
+ decision = data["decision"] in valid_boolean_trues
+ user_id = current_user.get_name()
+
+ result = self._set_decision(user_token, decision, user_id)
+ if not result:
+ return flask.abort(404)
+
+ return NO_CONTENT
+
+ def is_blueprint_protected(self):
+ return False # No API key required to request API access
+
+ ##~~ SimpleApiPlugin mixin
+
+ def get_api_commands(self):
+ return dict(generate=["app"],
+ revoke=["key"])
+
+ def on_api_get(self, request):
+ user_id = current_user.get_name()
+ if not user_id:
+ return flask.abort(403)
+
+ return flask.jsonify(keys=map(lambda x: x.external(), self._api_keys_for_user(user_id)),
+ pending=dict((x.user_token, x.external()) for x in self._get_pending(user_id)))
+
+ def on_api_command(self, command, data):
+ user_id = current_user.get_name()
+ if not user_id:
+ return flask.abort(403)
+
+ if command == "revoke":
+ api_key = data.get("key")
+ if not api_key:
+ return flask.abort(400)
+
+ self._delete_api_key(user_id, api_key)
+
+ elif command == "generate":
+ # manual generateKey
+ app_name = data.get("app")
+ if not app_name:
+ return flask.abort(400)
+
+ api_key = self._generate_key()
+ try:
+ self._add_api_key(user_id, app_name.trim(), api_key)
+ except AppAlreadyExists:
+ return flask.abort(409)
+
+ return NO_CONTENT
+
+ ##~~ key validator hook
+
+ def validate_api_key(self, api_key, *args, **kwargs):
+ return self._user_for_api_key(api_key)
+
+ ##~~ Helpers
+
+ def _add_pending_decision(self, app_name, user_id=None):
+ app_token = self._generate_key()
+ user_token = self._generate_key()
+
+ with self._pending_lock:
+ self._pending_decisions.append(PendingDecision(app_name, app_token, user_id, user_token))
+
+ return app_token, user_token
+
+ def _is_pending(self, app_token):
+ with self._pending_lock:
+ for data in self._pending_decisions:
+ if data.app_token == app_token:
+ return True
+
+ return False
+
+ def _get_pending(self, user_id):
+ result = []
+ with self._pending_lock:
+ for data in self._pending_decisions:
+ if data.user_id == user_id or data.user_id is None:
+ result.append(data)
+ return result
+
+ def _set_decision(self, user_token, decision, user_id):
+ with self._pending_lock:
+ for data in self._pending_decisions:
+ if data.user_token == user_token and (data.user_id == user_id or data.user_id is None):
+ pending = data
+ break
+ else:
+ return False # not found
+
+ if decision:
+ with self._ready_lock:
+ self._ready_decisions.append(ReadyDecision.for_pending(pending, self._generate_key()))
+
+ with self._pending_lock:
+ self._pending_decisions = filter(lambda x: x.user_token != user_token, self._pending_decisions)
+
+ return True
+
+ def _get_decision(self, app_token):
+ with self._ready_lock:
+ for data in self._ready_decisions:
+ if data.app_token == app_token:
+ decision = data
+ break
+ else:
+ return False # not found
+
+ self._add_api_key(decision.user_id, decision.app_id, decision.api_key)
+
+ with self._ready_lock:
+ self._ready_decisions = filter(lambda x: x.app_token != app_token, self._ready_decisions)
+
+ return decision.api_key
+
+ def _add_api_key(self, user_id, app_name, api_key):
+ with self._keys_lock:
+ # TODO: persist to disk
+ for key in self._keys[user_id]:
+ if key.app_id.lower() == app_name.lower():
+ raise AppAlreadyExists("app {} does already exist".format(app_name))
+ self._keys[user_id].append(ActiveKey(app_name, api_key))
+
+ def _delete_api_key(self, user_id, api_key):
+ with self._keys_lock:
+ # TODO: persist to disk
+ self._keys[user_id] = filter(lambda x: x.api_key != api_key, self._keys[user_id])
+
+ def _user_for_api_key(self, api_key):
+ with self._keys_lock:
+ for user_id, data in self._keys.items():
+ if filter(lambda x: x.api_key == api_key, data):
+ return self._user_manager.findUser(userid=user_id)
+ return None
+
+ def _api_keys_for_user(self, user_id):
+ with self._keys_lock:
+ return self._keys.get(user_id, [])
+
+ def _generate_key(self):
+ return hexlify(os.urandom(16))
+
+__plugin_name__ = "AppAuth Plugin"
+__plugin_description__ = "TODO"
+__plugin_author__ = "Gina Häußge, Aldo Hoeben"
+__plugin_implementation__ = AppAuthPlugin()
+__plugin_hooks__ = {
+ "octoprint.accesscontrol.keyvalidator": __plugin_implementation__.validate_api_key
+}
diff --git a/src/octoprint/plugins/appauth/static/js/appauth.js b/src/octoprint/plugins/appauth/static/js/appauth.js
new file mode 100644
index 000000000..74ec1e6e1
--- /dev/null
+++ b/src/octoprint/plugins/appauth/static/js/appauth.js
@@ -0,0 +1,169 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintAppAuthClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintAppAuthClient.prototype.getKeys = function(opts) {
+ return this.base.simpleApiGet("appauth", opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.generateKey = function(app, opts) {
+ return this.base.simpleApiCommand("appauth", "generate", {"app": app}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.revokeKey = function(key, opts) {
+ return this.base.simpleApiCommand("appauth", "revoke", {"key": key}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.decide = function(token, decision, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appauth") + "decision/" + token, {decision: !!decision}, opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("appauth", OctoPrintAppAuthClient);
+ return OctoPrintAppAuthClient;
+});
+
+$(function() {
+ function AppAuthViewModel(parameters) {
+ var self = this;
+ self.loginState = parameters[0];
+
+ self.keys = new ItemListHelper(
+ "plugin.appauth.keys",
+ {
+ "app": function (a, b) {
+ // sorts descending
+ if (a["app"] > b["app"]) return -1;
+ if (a["app"] < b["app"]) return 1;
+ return 0;
+ }
+ },
+ {
+ },
+ "app",
+ [],
+ [],
+ 10
+ );
+ self.pending = {};
+ self.openRequests = {};
+
+ self.editorApp = ko.observable();
+
+ self.requestData = function() {
+ OctoPrint.plugins.appauth.getKeys()
+ .done(self.fromResponse);
+ };
+
+ self.fromResponse = function(response) {
+ self.keys.updateItems(response.keys);
+ self.pending = response.pending;
+ _.each(self.pending, function(data, token) {
+ self.openRequests[token] = self.promptForAccess(data.app_id, token);
+ })
+ };
+
+ self.generateKey = function() {
+ return OctoPrint.plugins.appauth.generateKey(self.editorApp())
+ .done(self.requestData);
+ };
+
+ self.revokeKey = function(key) {
+ return OctoPrint.plugins.appauth.revokeKey(key)
+ .done(self.requestData);
+ };
+
+ self.allowApp = function(token) {
+ return OctoPrint.plugins.appauth.decide(token, true)
+ .done(self.requestData);
+ };
+
+ self.denyApp = function(token) {
+ return OctoPrint.plugins.appauth.decide(token, false)
+ .done(self.requestData);
+ };
+
+ self.promptForAccess = function(app, token) {
+ var message = gettext("\"%(app)s\" has requested access to control OctoPrint through the API. Do you want to allow access to this application with your user account?");
+ message = _.sprintf(message, {app: app});
+
+ return new PNotify({
+ title: gettext("Access Request"),
+ text: message,
+ confirm: {
+ confirm: true,
+ buttons: [{
+ text: gettext("Allow"),
+ click: function(notice) {
+ self.allowApp(token);
+ }
+ }, {
+ text: gettext("Deny"),
+ click: function(notice) {
+ self.denyApp(token);
+ }
+ }]
+ },
+ buttons: {
+ sticker: false,
+ closer: false
+ }
+ });
+ };
+
+ self.onUserSettingsShown = function() {
+ self.requestData();
+ };
+
+ self.onUserLoggedIn = function() {
+ self.requestData();
+ };
+
+ self.onDataUpdaterPluginMessage = function(plugin, data) {
+ if (plugin !== "appauth") {
+ return;
+ }
+
+ var app, token, user;
+
+ if (data.type === "request_access" && self.loginState.isUser()) {
+ app = data.app_name;
+ token = data.user_token;
+ user = data.user_id;
+
+ if (user && user !== self.loginState.username()) {
+ return;
+ }
+
+ if (self.pending[token] === undefined) {
+ return;
+ }
+
+ self.openRequests[token] = self.promptForAccess(app, token);
+
+ } else if (data.type === "end_request") {
+ token = data.user_token;
+
+ if (self.openRequests[token] !== undefined) {
+ // another instance responded to the access request before the current user did
+ if (self.openRequests[token].state !== "closed") {
+ self.openRequests[token].remove();
+ }
+ delete self.openRequests[token]
+ }
+ }
+ };
+ }
+
+ OCTOPRINT_VIEWMODELS.push([
+ AppAuthViewModel,
+ ["loginStateViewModel"],
+ ["#usersettings_plugin_appauth"]
+ ]);
+});
diff --git a/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2 b/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
new file mode 100644
index 000000000..aeb2f9e67
--- /dev/null
+++ b/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
@@ -0,0 +1,42 @@
+
+
+
+ {{ _('Application') }}
+ {{ _('Action') }}
+
+
+
+
+ {{ _('API Key') }}:
+
+
+
+
+
+
+
+
+
From 4f58c64881b08a3976d79015aa47bc9f6370d049 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Tue, 28 Aug 2018 22:02:18 +0200
Subject: [PATCH 016/183] New asset type "clientjs" for client library bits
---
.../plugins/action_command_prompt/__init__.py | 3 +-
.../static/clientjs/action_command_prompt.js | 25 ++++++
.../static/js/action_command_prompt.js | 26 ------
src/octoprint/plugins/backup/__init__.py | 1 +
.../plugins/backup/static/clientjs/backup.js | 52 ++++++++++++
.../plugins/backup/static/js/backup.js | 53 ------------
src/octoprint/plugins/logging/__init__.py | 1 +
.../logging/static/clientjs/logging.js | 68 +++++++++++++++
.../plugins/logging/static/js/logging.js | 69 ---------------
src/octoprint/plugins/pi_support/__init__.py | 1 +
.../pi_support/static/clientjs/pi_support.js | 19 +++++
.../pi_support/static/js/pi_support.js | 19 -----
.../plugins/pluginmanager/__init__.py | 1 +
.../static/clientjs/pluginmanager.js | 82 ++++++++++++++++++
.../pluginmanager/static/js/pluginmanager.js | 83 ------------------
.../plugins/printer_safety_check/__init__.py | 1 +
.../static/clientjs/printer_safety_check.js | 18 ++++
.../static/js/printer_safety_check.js | 19 -----
.../plugins/softwareupdate/__init__.py | 1 +
.../static/clientjs/softwareupdate.js | 84 ++++++++++++++++++
.../static/js/softwareupdate.js | 85 -------------------
src/octoprint/server/__init__.py | 47 +++++-----
src/octoprint/server/util/flask.py | 29 +++++++
23 files changed, 410 insertions(+), 377 deletions(-)
create mode 100644 src/octoprint/plugins/action_command_prompt/static/clientjs/action_command_prompt.js
create mode 100644 src/octoprint/plugins/backup/static/clientjs/backup.js
create mode 100644 src/octoprint/plugins/logging/static/clientjs/logging.js
create mode 100644 src/octoprint/plugins/pi_support/static/clientjs/pi_support.js
create mode 100644 src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js
create mode 100644 src/octoprint/plugins/printer_safety_check/static/clientjs/printer_safety_check.js
create mode 100644 src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js
diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py
index 0dd9a4be2..8900c5d7a 100644
--- a/src/octoprint/plugins/action_command_prompt/__init__.py
+++ b/src/octoprint/plugins/action_command_prompt/__init__.py
@@ -49,7 +49,8 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin,
#~ AssetPlugin
def get_assets(self):
- return dict(js=["js/action_command_prompt.js"])
+ return dict(js=["js/action_command_prompt.js"],
+ clientjs=["clientjs/action_command_prompt.js"])
#~ SettingsPlugin
diff --git a/src/octoprint/plugins/action_command_prompt/static/clientjs/action_command_prompt.js b/src/octoprint/plugins/action_command_prompt/static/clientjs/action_command_prompt.js
new file mode 100644
index 000000000..9ba9b4a14
--- /dev/null
+++ b/src/octoprint/plugins/action_command_prompt/static/clientjs/action_command_prompt.js
@@ -0,0 +1,25 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintActionCommandPromptClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintActionCommandPromptClient.prototype.get = function(refresh, opts) {
+ return this.base.get(this.base.getSimpleApiUrl("action_command_prompt"), opts);
+ };
+
+ OctoPrintActionCommandPromptClient.prototype.select = function(choice, opts) {
+ var data = {
+ choice: choice
+ };
+ return this.base.simpleApiCommand("action_command_prompt", "select", data, opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("action_command_prompt", OctoPrintActionCommandPromptClient);
+ return OctoPrintActionCommandPromptClient;
+});
diff --git a/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js b/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js
index 6298a5338..e077903a2 100644
--- a/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js
+++ b/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js
@@ -1,29 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintActionCommandPromptClient = function(base) {
- this.base = base;
- };
-
- OctoPrintActionCommandPromptClient.prototype.get = function(refresh, opts) {
- return this.base.get(this.base.getSimpleApiUrl("action_command_prompt"), opts);
- };
-
- OctoPrintActionCommandPromptClient.prototype.select = function(choice, opts) {
- var data = {
- choice: choice
- };
- return this.base.simpleApiCommand("action_command_prompt", "select", data, opts);
- };
-
- OctoPrintClient.registerPluginComponent("action_command_prompt", OctoPrintActionCommandPromptClient);
- return OctoPrintActionCommandPromptClient;
-});
-
$(function() {
function ActionCommandPromptViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py
index 47ceb0a31..e687b3b85 100644
--- a/src/octoprint/plugins/backup/__init__.py
+++ b/src/octoprint/plugins/backup/__init__.py
@@ -69,6 +69,7 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin,
def get_assets(self):
return dict(js=["js/backup.js"],
+ clientjs=["clientjs/backup.js"],
css=["css/backup.css"],
less=["less/backup.less"])
diff --git a/src/octoprint/plugins/backup/static/clientjs/backup.js b/src/octoprint/plugins/backup/static/clientjs/backup.js
new file mode 100644
index 000000000..5f2ee6e62
--- /dev/null
+++ b/src/octoprint/plugins/backup/static/clientjs/backup.js
@@ -0,0 +1,52 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintBackupClient = function(base) {
+ this.base = base;
+ this.url = this.base.getBlueprintUrl("backup");
+ };
+
+ OctoPrintBackupClient.prototype.get = function(refresh, opts) {
+ return this.base.get(this.url, opts);
+ };
+
+ OctoPrintBackupClient.prototype.createBackup = function(exclude, opts) {
+ exclude = exclude || [];
+
+ var data = {
+ exclude: exclude
+ };
+
+ return this.base.postJson(this.url + "backup", data, opts);
+ };
+
+ OctoPrintBackupClient.prototype.deleteBackup = function(backup, opts) {
+ return this.base.delete(this.url + "backup/" + backup, opts);
+ };
+
+ OctoPrintBackupClient.prototype.restoreBackup = function(backup, opts) {
+ var data = {
+ path: backup
+ };
+
+ return this.base.postJson(this.url + "restore", data, opts);
+ };
+
+ OctoPrintBackupClient.prototype.restoreBackupFromUpload = function (file, data) {
+ data = data || {};
+
+ var filename = data.filename || undefined;
+ return this.base.upload(this.url + "restore", file, filename, data);
+ };
+
+ OctoPrintBackupClient.prototype.deleteUnknownPlugins = function (opts) {
+ return this.base.delete(this.url + "unknown_plugins", opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("backup", OctoPrintBackupClient);
+ return OctoPrintBackupClient;
+});
diff --git a/src/octoprint/plugins/backup/static/js/backup.js b/src/octoprint/plugins/backup/static/js/backup.js
index 61eedb240..dadd24c8c 100644
--- a/src/octoprint/plugins/backup/static/js/backup.js
+++ b/src/octoprint/plugins/backup/static/js/backup.js
@@ -1,56 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintBackupClient = function(base) {
- this.base = base;
- this.url = this.base.getBlueprintUrl("backup");
- };
-
- OctoPrintBackupClient.prototype.get = function(refresh, opts) {
- return this.base.get(this.url, opts);
- };
-
- OctoPrintBackupClient.prototype.createBackup = function(exclude, opts) {
- exclude = exclude || [];
-
- var data = {
- exclude: exclude
- };
-
- return this.base.postJson(this.url + "backup", data, opts);
- };
-
- OctoPrintBackupClient.prototype.deleteBackup = function(backup, opts) {
- return this.base.delete(this.url + "backup/" + backup, opts);
- };
-
- OctoPrintBackupClient.prototype.restoreBackup = function(backup, opts) {
- var data = {
- path: backup
- };
-
- return this.base.postJson(this.url + "restore", data, opts);
- };
-
- OctoPrintBackupClient.prototype.restoreBackupFromUpload = function (file, data) {
- data = data || {};
-
- var filename = data.filename || undefined;
- return this.base.upload(this.url + "restore", file, filename, data);
- };
-
- OctoPrintBackupClient.prototype.deleteUnknownPlugins = function (opts) {
- return this.base.delete(this.url + "unknown_plugins", opts);
- };
-
- OctoPrintClient.registerPluginComponent("backup", OctoPrintBackupClient);
- return OctoPrintBackupClient;
-});
-
$(function() {
function BackupViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/logging/__init__.py b/src/octoprint/plugins/logging/__init__.py
index ed11c1c28..9b7c9bd74 100644
--- a/src/octoprint/plugins/logging/__init__.py
+++ b/src/octoprint/plugins/logging/__init__.py
@@ -195,6 +195,7 @@ class LoggingPlugin(octoprint.plugin.AssetPlugin,
def get_assets(self):
return dict(js=["js/logging.js"],
+ clientjs=["clientjs/logging.js"],
less=["less/logging.less"],
css=["css/logging.css"])
diff --git a/src/octoprint/plugins/logging/static/clientjs/logging.js b/src/octoprint/plugins/logging/static/clientjs/logging.js
new file mode 100644
index 000000000..23b90f85d
--- /dev/null
+++ b/src/octoprint/plugins/logging/static/clientjs/logging.js
@@ -0,0 +1,68 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+
+ var OctoPrintLoggingClient = function(base) {
+ this.base = base;
+
+ this.baseUrl = this.base.getBlueprintUrl("logging");
+ this.logsUrl = this.baseUrl + "logs";
+ this.setupUrl = this.baseUrl + "setup";
+ };
+
+ OctoPrintLoggingClient.prototype.get = function(opts) {
+ return this.base.get(this.baseUrl, opts);
+ };
+
+ OctoPrintLoggingClient.prototype.listLogs = function(opts) {
+ return this.base.get(this.logsUrl, opts);
+ };
+
+ OctoPrintLoggingClient.prototype.deleteLog = function(file, opts) {
+ var fileUrl = this.logsUrl + "/" + file;
+ return this.base.delete(fileUrl, opts);
+ };
+
+ OctoPrintLoggingClient.prototype.downloadLog = function(file, opts) {
+ var fileUrl = this.logsUrl + "/" + file;
+ return this.base.download(fileUrl, opts);
+ };
+
+ OctoPrintLoggingClient.prototype.updateLevels = function(config, opts) {
+ return this.base.putJson(this.setupUrl + "/levels", config, opts);
+ };
+
+ //~~ wrapper for backwards compatibility
+
+ var DeprecatedOctoPrintLogsClient = function(base) {
+ this.base = base;
+ this.wrapped = this.base.plugins.logging;
+ };
+
+ DeprecatedOctoPrintLogsClient.prototype.list = function(opts) {
+ log.warn("OctoPrintClient.logs.list has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.listLogs instead");
+ return this.wrapped.listLogs(opts);
+ };
+
+ DeprecatedOctoPrintLogsClient.prototype.delete = function(file, opts) {
+ log.warn("OctoPrintClient.logs.delete has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.deleteLog instead");
+ return this.wrapped.deleteLog(file, opts);
+ };
+
+ DeprecatedOctoPrintLogsClient.prototype.download = function(file, opts) {
+ log.warn("OctoPrintClient.logs.download has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.downloadLog instead");
+ return this.wrapped.downloadLog(file, opts);
+ };
+
+ // register plugin component
+ OctoPrintClient.registerPluginComponent("logging", OctoPrintLoggingClient);
+
+ // also register deprecated client under old endpoint
+ OctoPrintClient.registerComponent("logs", DeprecatedOctoPrintLogsClient);
+
+ return OctoPrintLoggingClient;
+});
diff --git a/src/octoprint/plugins/logging/static/js/logging.js b/src/octoprint/plugins/logging/static/js/logging.js
index c4131debb..2f0f16988 100644
--- a/src/octoprint/plugins/logging/static/js/logging.js
+++ b/src/octoprint/plugins/logging/static/js/logging.js
@@ -1,72 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
-
- var OctoPrintLoggingClient = function(base) {
- this.base = base;
-
- this.baseUrl = this.base.getBlueprintUrl("logging");
- this.logsUrl = this.baseUrl + "logs";
- this.setupUrl = this.baseUrl + "setup";
- };
-
- OctoPrintLoggingClient.prototype.get = function(opts) {
- return this.base.get(this.baseUrl, opts);
- };
-
- OctoPrintLoggingClient.prototype.listLogs = function(opts) {
- return this.base.get(this.logsUrl, opts);
- };
-
- OctoPrintLoggingClient.prototype.deleteLog = function(file, opts) {
- var fileUrl = this.logsUrl + "/" + file;
- return this.base.delete(fileUrl, opts);
- };
-
- OctoPrintLoggingClient.prototype.downloadLog = function(file, opts) {
- var fileUrl = this.logsUrl + "/" + file;
- return this.base.download(fileUrl, opts);
- };
-
- OctoPrintLoggingClient.prototype.updateLevels = function(config, opts) {
- return this.base.putJson(this.setupUrl + "/levels", config, opts);
- };
-
- //~~ wrapper for backwards compatibility
-
- var DeprecatedOctoPrintLogsClient = function(base) {
- this.base = base;
- this.wrapped = this.base.plugins.logging;
- };
-
- DeprecatedOctoPrintLogsClient.prototype.list = function(opts) {
- log.warn("OctoPrintClient.logs.list has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.listLogs instead");
- return this.wrapped.listLogs(opts);
- };
-
- DeprecatedOctoPrintLogsClient.prototype.delete = function(file, opts) {
- log.warn("OctoPrintClient.logs.delete has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.deleteLog instead");
- return this.wrapped.deleteLog(file, opts);
- };
-
- DeprecatedOctoPrintLogsClient.prototype.download = function(file, opts) {
- log.warn("OctoPrintClient.logs.download has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.downloadLog instead");
- return this.wrapped.downloadLog(file, opts);
- };
-
- // register plugin component
- OctoPrintClient.registerPluginComponent("logging", OctoPrintLoggingClient);
-
- // also register deprecated client under old endpoint
- OctoPrintClient.registerComponent("logs", DeprecatedOctoPrintLogsClient);
-
- return OctoPrintLoggingClient;
-});
-
$(function() {
function LoggingViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/pi_support/__init__.py b/src/octoprint/plugins/pi_support/__init__.py
index e0bd9ac10..28b4f3d03 100644
--- a/src/octoprint/plugins/pi_support/__init__.py
+++ b/src/octoprint/plugins/pi_support/__init__.py
@@ -193,6 +193,7 @@ class PiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin,
def get_assets(self):
return dict(
js=["js/pi_support.js"],
+ clientjs=["clientjs/pi_support.js"],
css=["css/pi_support.css"]
)
diff --git a/src/octoprint/plugins/pi_support/static/clientjs/pi_support.js b/src/octoprint/plugins/pi_support/static/clientjs/pi_support.js
new file mode 100644
index 000000000..7c216aa0f
--- /dev/null
+++ b/src/octoprint/plugins/pi_support/static/clientjs/pi_support.js
@@ -0,0 +1,19 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintPiSupportClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintPiSupportClient.prototype.get = function(opts) {
+ return this.base.get(this.base.getSimpleApiUrl("pi_support"));
+ };
+
+ OctoPrintClient.registerPluginComponent("pi_support", OctoPrintPiSupportClient);
+ return OctoPrintPiSupportClient;
+});
+
diff --git a/src/octoprint/plugins/pi_support/static/js/pi_support.js b/src/octoprint/plugins/pi_support/static/js/pi_support.js
index ced2a55e4..2516a4f77 100644
--- a/src/octoprint/plugins/pi_support/static/js/pi_support.js
+++ b/src/octoprint/plugins/pi_support/static/js/pi_support.js
@@ -1,22 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintPiSupportClient = function(base) {
- this.base = base;
- };
-
- OctoPrintPiSupportClient.prototype.get = function(opts) {
- return this.base.get(this.base.getSimpleApiUrl("pi_support"));
- };
-
- OctoPrintClient.registerPluginComponent("pi_support", OctoPrintPiSupportClient);
- return OctoPrintPiSupportClient;
-});
-
$(function() {
function PiSupportViewModel(parameters) {
diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py
index df4def7e6..c085c032e 100644
--- a/src/octoprint/plugins/pluginmanager/__init__.py
+++ b/src/octoprint/plugins/pluginmanager/__init__.py
@@ -168,6 +168,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
def get_assets(self):
return dict(
js=["js/pluginmanager.js"],
+ clientjs=["clientjs/pluginmanager.js"],
css=["css/pluginmanager.css"],
less=["less/pluginmanager.less"]
)
diff --git a/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js b/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js
new file mode 100644
index 000000000..acaaf3590
--- /dev/null
+++ b/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js
@@ -0,0 +1,82 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintPluginManagerClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintPluginManagerClient.prototype.get = function(refresh, opts) {
+ var refresh_repo, refresh_notices;
+ if (_.isPlainObject(refresh)) {
+ refresh_repo = refresh.repo || false;
+ refresh_notices = refresh.notices || false;
+ } else {
+ refresh_repo = refresh;
+ refresh_notices = false;
+ }
+
+ var query = [];
+ if (refresh_repo) query.push("refresh_repository=true");
+ if (refresh_notices) query.push("refresh_notices=true");
+
+ return this.base.get(this.base.getSimpleApiUrl("pluginmanager") + ((query.length) ? "?" + query.join("&") : ""), opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.getWithRefresh = function(opts) {
+ return this.get(true, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.getWithoutRefresh = function(opts) {
+ return this.get(false, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.install = function(pluginUrl, dependencyLinks, opts) {
+ var data = {
+ url: pluginUrl,
+ dependency_links: !!dependencyLinks
+ };
+ return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.reinstall = function(plugin, pluginUrl, dependencyLinks, opts) {
+ var data = {
+ url: pluginUrl,
+ dependency_links: !!dependencyLinks,
+ reinstall: plugin,
+ force: true
+ };
+ return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.uninstall = function(plugin, opts) {
+ var data = {
+ plugin: plugin
+ };
+ return this.base.simpleApiCommand("pluginmanager", "uninstall", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.enable = function(plugin, opts) {
+ var data = {
+ plugin: plugin
+ };
+ return this.base.simpleApiCommand("pluginmanager", "enable", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.disable = function(plugin, opts) {
+ var data = {
+ plugin: plugin
+ };
+ return this.base.simpleApiCommand("pluginmanager", "disable", data, opts);
+ };
+
+ OctoPrintPluginManagerClient.prototype.upload = function(file) {
+ return this.base.upload(this.base.getBlueprintUrl("pluginmanager") + "upload_archive", file);
+ };
+
+ OctoPrintClient.registerPluginComponent("pluginmanager", OctoPrintPluginManagerClient);
+ return OctoPrintPluginManagerClient;
+});
diff --git a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
index 5bf20baef..403aae500 100644
--- a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
+++ b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
@@ -1,86 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintPluginManagerClient = function(base) {
- this.base = base;
- };
-
- OctoPrintPluginManagerClient.prototype.get = function(refresh, opts) {
- var refresh_repo, refresh_notices;
- if (_.isPlainObject(refresh)) {
- refresh_repo = refresh.repo || false;
- refresh_notices = refresh.notices || false;
- } else {
- refresh_repo = refresh;
- refresh_notices = false;
- }
-
- var query = [];
- if (refresh_repo) query.push("refresh_repository=true");
- if (refresh_notices) query.push("refresh_notices=true");
-
- return this.base.get(this.base.getSimpleApiUrl("pluginmanager") + ((query.length) ? "?" + query.join("&") : ""), opts);
- };
-
- OctoPrintPluginManagerClient.prototype.getWithRefresh = function(opts) {
- return this.get(true, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.getWithoutRefresh = function(opts) {
- return this.get(false, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.install = function(pluginUrl, dependencyLinks, opts) {
- var data = {
- url: pluginUrl,
- dependency_links: !!dependencyLinks
- };
- return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.reinstall = function(plugin, pluginUrl, dependencyLinks, opts) {
- var data = {
- url: pluginUrl,
- dependency_links: !!dependencyLinks,
- reinstall: plugin,
- force: true
- };
- return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.uninstall = function(plugin, opts) {
- var data = {
- plugin: plugin
- };
- return this.base.simpleApiCommand("pluginmanager", "uninstall", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.enable = function(plugin, opts) {
- var data = {
- plugin: plugin
- };
- return this.base.simpleApiCommand("pluginmanager", "enable", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.disable = function(plugin, opts) {
- var data = {
- plugin: plugin
- };
- return this.base.simpleApiCommand("pluginmanager", "disable", data, opts);
- };
-
- OctoPrintPluginManagerClient.prototype.upload = function(file) {
- return this.base.upload(this.base.getBlueprintUrl("pluginmanager") + "upload_archive", file);
- };
-
- OctoPrintClient.registerPluginComponent("pluginmanager", OctoPrintPluginManagerClient);
- return OctoPrintPluginManagerClient;
-});
-
$(function() {
function PluginManagerViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/printer_safety_check/__init__.py b/src/octoprint/plugins/printer_safety_check/__init__.py
index 182f61a3e..677bef7fd 100644
--- a/src/octoprint/plugins/printer_safety_check/__init__.py
+++ b/src/octoprint/plugins/printer_safety_check/__init__.py
@@ -90,6 +90,7 @@ class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin,
def get_assets(self):
return dict(js=("js/printer_safety_check.js",),
+ clientjs=("clientjs/printer_safety_check.js",),
css=("css/printer_safety_check.css",),
less=("less/printer_safety_check.less",))
diff --git a/src/octoprint/plugins/printer_safety_check/static/clientjs/printer_safety_check.js b/src/octoprint/plugins/printer_safety_check/static/clientjs/printer_safety_check.js
new file mode 100644
index 000000000..5a52fc4f9
--- /dev/null
+++ b/src/octoprint/plugins/printer_safety_check/static/clientjs/printer_safety_check.js
@@ -0,0 +1,18 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintPrinterSafetyCheckClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintPrinterSafetyCheckClient.prototype.get = function(opts) {
+ return this.base.get(this.base.getSimpleApiUrl("printer_safety_check"), opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("printer_safety_check", OctoPrintPrinterSafetyCheckClient);
+ return OctoPrintPrinterSafetyCheckClient;
+});
diff --git a/src/octoprint/plugins/printer_safety_check/static/js/printer_safety_check.js b/src/octoprint/plugins/printer_safety_check/static/js/printer_safety_check.js
index c69bf8eb6..34e75aa97 100644
--- a/src/octoprint/plugins/printer_safety_check/static/js/printer_safety_check.js
+++ b/src/octoprint/plugins/printer_safety_check/static/js/printer_safety_check.js
@@ -1,22 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintPrinterSafetyCheckClient = function(base) {
- this.base = base;
- };
-
- OctoPrintPrinterSafetyCheckClient.prototype.get = function(opts) {
- return this.base.get(this.base.getSimpleApiUrl("printer_safety_check"), opts);
- };
-
- OctoPrintClient.registerPluginComponent("printer_safety_check", OctoPrintPrinterSafetyCheckClient);
- return OctoPrintPrinterSafetyCheckClient;
-});
-
$(function() {
function PrinterSafetyCheckViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py
index 2166d293b..bd13f2a3d 100644
--- a/src/octoprint/plugins/softwareupdate/__init__.py
+++ b/src/octoprint/plugins/softwareupdate/__init__.py
@@ -560,6 +560,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
return dict(
css=["css/softwareupdate.css"],
js=["js/softwareupdate.js"],
+ clientjs=["clientjs/softwareupdate.js"],
less=["less/softwareupdate.less"]
)
diff --git a/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js
new file mode 100644
index 000000000..932dcf8ce
--- /dev/null
+++ b/src/octoprint/plugins/softwareupdate/static/clientjs/softwareupdate.js
@@ -0,0 +1,84 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintSoftwareUpdateClient = function(base) {
+ this.base = base;
+
+ var url = this.base.getBlueprintUrl("softwareupdate");
+ this.checkUrl = url + "check";
+ this.updateUrl = url + "update";
+ };
+
+ OctoPrintSoftwareUpdateClient.prototype.checkEntries = function(entries, force, opts) {
+ if (arguments.length == 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ entries = params.entries;
+ force = params.force;
+ opts = params.opts;
+ }
+
+ entries = entries || [];
+ if (typeof entries == "string") {
+ entries = [entries];
+ }
+
+ var data = {};
+ if (!!force) {
+ data.force = true;
+ }
+ if (entries && entries.length) {
+ data.check = entries.join(",");
+ }
+ return this.base.getWithQuery(this.checkUrl, data, opts);
+ };
+
+ OctoPrintSoftwareUpdateClient.prototype.check = function(force, opts) {
+ if (arguments.length === 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ force = params.force;
+ opts = params.opts;
+ }
+
+ return this.checkEntries({entries: [], force: force, opts: opts});
+ };
+
+ OctoPrintSoftwareUpdateClient.prototype.update = function(targets, force, opts) {
+ if (arguments.length === 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ targets = params.targets;
+ force = params.force;
+ opts = params.opts;
+ }
+
+ targets = targets || [];
+ if (typeof targets === "string") {
+ targets = [targets];
+ }
+
+ var data = {
+ targets: targets,
+ force: !!force
+ };
+ return this.base.postJson(this.updateUrl, data, opts);
+ };
+
+ OctoPrintSoftwareUpdateClient.prototype.updateAll = function(force, opts) {
+ if (arguments.length === 1 && _.isObject(arguments[0])) {
+ var params = arguments[0];
+ force = params.force;
+ opts = params.opts;
+ }
+
+ var data = {
+ force: !!force
+ };
+ return this.base.postJson(this.updateUrl, data, opts);
+ };
+
+ OctoPrintClient.registerPluginComponent("softwareupdate", OctoPrintSoftwareUpdateClient);
+ return OctoPrintSoftwareUpdateClient;
+});
diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
index d0484a5b8..fbe341dae 100644
--- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
+++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
@@ -1,88 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintSoftwareUpdateClient = function(base) {
- this.base = base;
-
- var url = this.base.getBlueprintUrl("softwareupdate");
- this.checkUrl = url + "check";
- this.updateUrl = url + "update";
- };
-
- OctoPrintSoftwareUpdateClient.prototype.checkEntries = function(entries, force, opts) {
- if (arguments.length == 1 && _.isObject(arguments[0])) {
- var params = arguments[0];
- entries = params.entries;
- force = params.force;
- opts = params.opts;
- }
-
- entries = entries || [];
- if (typeof entries == "string") {
- entries = [entries];
- }
-
- var data = {};
- if (!!force) {
- data.force = true;
- }
- if (entries && entries.length) {
- data.check = entries.join(",");
- }
- return this.base.getWithQuery(this.checkUrl, data, opts);
- };
-
- OctoPrintSoftwareUpdateClient.prototype.check = function(force, opts) {
- if (arguments.length === 1 && _.isObject(arguments[0])) {
- var params = arguments[0];
- force = params.force;
- opts = params.opts;
- }
-
- return this.checkEntries({entries: [], force: force, opts: opts});
- };
-
- OctoPrintSoftwareUpdateClient.prototype.update = function(targets, force, opts) {
- if (arguments.length === 1 && _.isObject(arguments[0])) {
- var params = arguments[0];
- targets = params.targets;
- force = params.force;
- opts = params.opts;
- }
-
- targets = targets || [];
- if (typeof targets === "string") {
- targets = [targets];
- }
-
- var data = {
- targets: targets,
- force: !!force
- };
- return this.base.postJson(this.updateUrl, data, opts);
- };
-
- OctoPrintSoftwareUpdateClient.prototype.updateAll = function(force, opts) {
- if (arguments.length === 1 && _.isObject(arguments[0])) {
- var params = arguments[0];
- force = params.force;
- opts = params.opts;
- }
-
- var data = {
- force: !!force
- };
- return this.base.postJson(this.updateUrl, data, opts);
- };
-
- OctoPrintClient.registerPluginComponent("softwareupdate", OctoPrintSoftwareUpdateClient);
- return OctoPrintSoftwareUpdateClient;
-});
-
$(function() {
function SoftwareUpdateViewModel(parameters) {
var self = this;
diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py
index 71e676e4d..c751b59dd 100644
--- a/src/octoprint/server/__init__.py
+++ b/src/octoprint/server/__init__.py
@@ -1348,25 +1348,6 @@ class Server(object):
"js/lib/loglevel.min.js",
"js/lib/sockjs.js"
]
- js_client = [
- "js/app/client/base.js",
- "js/app/client/socket.js",
- "js/app/client/browser.js",
- "js/app/client/connection.js",
- "js/app/client/control.js",
- "js/app/client/files.js",
- "js/app/client/job.js",
- "js/app/client/languages.js",
- "js/app/client/printer.js",
- "js/app/client/printerprofiles.js",
- "js/app/client/settings.js",
- "js/app/client/slicing.js",
- "js/app/client/system.js",
- "js/app/client/timelapse.js",
- "js/app/client/users.js",
- "js/app/client/util.js",
- "js/app/client/wizard.js"
- ]
css_libs = [
"css/bootstrap.min.css",
@@ -1419,13 +1400,15 @@ class Server(object):
js_plugins = js_bundles_for_plugins(dynamic_plugin_assets["external"]["js"],
filters="js_delimiter_bundler")
+ clientjs_core = dynamic_core_assets["clientjs"] + \
+ all_assets_for_plugins(dynamic_plugin_assets["bundled"]["clientjs"])
+ clientjs_plugins = js_bundles_for_plugins(dynamic_plugin_assets["external"]["clientjs"],
+ filters="js_delimiter_bundler")
+
js_libs_bundle = Bundle(*js_libs,
output="webassets/packed_libs.js",
filters=",".join(js_filters))
- js_client_bundle = Bundle(*js_client,
- output="webassets/packed_client.js",
- filters=",".join(js_filters))
js_core_bundle = Bundle(*js_core,
output="webassets/packed_core.js",
filters=",".join(js_filters))
@@ -1441,6 +1424,21 @@ class Server(object):
output="webassets/packed_app.js",
filters=",".join(js_filters))
+ js_client_core_bundle = Bundle(*clientjs_core,
+ output="webassets/packed_client_core.js",
+ filters=",".join(js_filters))
+
+ if len(clientjs_plugins) == 0:
+ js_client_plugins_bundle = Bundle(*[])
+ else:
+ js_client_plugins_bundle = Bundle(*clientjs_plugins.values(),
+ output="webassets/packed_client_plugins.js",
+ filters=",".join(js_plugin_filters))
+
+ js_client_bundle = Bundle(js_client_core_bundle, js_client_plugins_bundle,
+ output="webassets/packed_client.js",
+ filters=",".join(js_filters))
+
# -- CSS -------------------------------------------------------------------------------------------------------
css_filters = ["cssrewrite"]
@@ -1500,6 +1498,11 @@ class Server(object):
# -- asset registration ----------------------------------------------------------------------------------------
assets.register("js_libs", js_libs_bundle)
+ assets.register("js_client_core", js_client_core_bundle)
+ for plugin, bundle in clientjs_plugins.items():
+ # register our collected clientjs plugin bundles so that they are bound to the environment
+ assets.register("js_client_plugin_{}".format(plugin), bundle)
+ assets.register("js_client_plugins", js_client_plugins_bundle)
assets.register("js_client", js_client_bundle)
assets.register("js_core", js_core_bundle)
for plugin, bundle in js_plugins.items():
diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py
index 1befcb36b..66bd47d46 100644
--- a/src/octoprint/server/util/flask.py
+++ b/src/octoprint/server/util/flask.py
@@ -1348,6 +1348,7 @@ class SettingsCheckUpdater(webassets.updater.BaseUpdater):
def collect_core_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
assets = dict(
js=[],
+ clientjs=[],
css=[],
less=[]
)
@@ -1389,6 +1390,26 @@ def collect_core_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
'gcodeviewer/js/renderer.js'
]
+ assets["clientjs"] = [
+ "js/app/client/base.js",
+ "js/app/client/socket.js",
+ "js/app/client/browser.js",
+ "js/app/client/connection.js",
+ "js/app/client/control.js",
+ "js/app/client/files.js",
+ "js/app/client/job.js",
+ "js/app/client/languages.js",
+ "js/app/client/printer.js",
+ "js/app/client/printerprofiles.js",
+ "js/app/client/settings.js",
+ "js/app/client/slicing.js",
+ "js/app/client/system.js",
+ "js/app/client/timelapse.js",
+ "js/app/client/users.js",
+ "js/app/client/util.js",
+ "js/app/client/wizard.js"
+ ]
+
if preferred_stylesheet == "less":
assets["less"].append('less/octoprint.less')
elif preferred_stylesheet == "css":
@@ -1403,9 +1424,11 @@ def collect_plugin_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
supported_stylesheets = ("css", "less")
assets = dict(bundled=dict(js=DefaultOrderedDict(list),
+ clientjs=DefaultOrderedDict(list),
css=DefaultOrderedDict(list),
less=DefaultOrderedDict(list)),
external=dict(js=DefaultOrderedDict(list),
+ clientjs=DefaultOrderedDict(list),
css=DefaultOrderedDict(list),
less=DefaultOrderedDict(list)))
@@ -1435,6 +1458,12 @@ def collect_plugin_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
continue
assets[asset_key]["js"][name].append('plugin/{name}/{asset}'.format(**locals()))
+ if "clientjs" in all_assets:
+ for asset in all_assets["clientjs"]:
+ if not asset_exists("clientjs", asset):
+ continue
+ assets[asset_key]["clientjs"][name].append("plugin/{name}/{asset}".format(**locals()))
+
if preferred_stylesheet in all_assets:
for asset in all_assets[preferred_stylesheet]:
if not asset_exists(preferred_stylesheet, asset):
From 469bf844ee5e59a1959366cc17acce7e2ba8c2a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Tue, 28 Aug 2018 22:02:40 +0200
Subject: [PATCH 017/183] Clientlib: support operation without api key
---
src/octoprint/static/js/app/client/base.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/octoprint/static/js/app/client/base.js b/src/octoprint/static/js/app/client/base.js
index 2eb51d4d9..f8e6b3ae0 100644
--- a/src/octoprint/static/js/app/client/base.js
+++ b/src/octoprint/static/js/app/client/base.js
@@ -111,7 +111,9 @@
additional = additional || {};
var headers = $.extend({}, additional);
- headers["X-Api-Key"] = this.options.apikey;
+ if (this.options.apikey) {
+ headers["X-Api-Key"] = this.options.apikey;
+ }
if (this.options.locale !== undefined) {
headers["X-Locale"] = this.options.locale;
From 6efd4dfd08785263f7ab6cde8d7bdad4792b8eb7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Tue, 28 Aug 2018 22:04:34 +0200
Subject: [PATCH 018/183] New options for confirmation dialog
* oncancel: callback to call when cancel button is pressed
* noclose: don't allow dismissing/closing the dialog without having
chosen to proceed or cancel
---
src/octoprint/static/js/app/helpers.js | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js
index 1eb161d05..7df9e46af 100644
--- a/src/octoprint/static/js/app/helpers.js
+++ b/src/octoprint/static/js/app/helpers.js
@@ -708,11 +708,19 @@ function showConfirmationDialog(msg, onacknowledge, options) {
var proceed = options.proceed || gettext("Proceed");
var proceedClass = options.proceedClass || "danger";
var onproceed = options.onproceed || undefined;
+ var oncancel = options.oncancel || undefined;
var onclose = options.onclose || undefined;
var dialogClass = options.dialogClass || "";
var nofade = options.nofade || false;
+ var noclose = options.noclose || false;
+
+ var modalHeader;
+ if (noclose) {
+ modalHeader = $('' + title + ' ');
+ } else {
+ modalHeader = $('× ' + title + ' ');
+ }
- var modalHeader = $('× ' + title + ' ');
var modalBody;
if (html) {
modalBody = $(html);
@@ -740,7 +748,13 @@ function showConfirmationDialog(msg, onacknowledge, options) {
onclose(event);
}
});
- modal.modal("show");
+
+ var modalOptions = {};
+ if (noclose) {
+ modalOptions.backdrop = "static";
+ modalOptions.keyboard = false;
+ }
+ modal.modal(modalOptions);
proceedButton.click(function(e) {
e.preventDefault();
@@ -749,6 +763,11 @@ function showConfirmationDialog(msg, onacknowledge, options) {
}
modal.modal("hide");
});
+ cancelButton.click(function(e) {
+ if (oncancel && _.isFunction(oncancel)) {
+ oncancel(e);
+ }
+ });
return modal;
}
From ad8205c386e0b5e09fa0f3505263876a54feb466 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Tue, 28 Aug 2018 22:05:28 +0200
Subject: [PATCH 019/183] AppAuth: workflow fully implemented & client lib
---
src/octoprint/plugins/appauth/__init__.py | 37 +++++----
.../appauth/static/clientjs/appauth.js | 83 +++++++++++++++++++
.../plugins/appauth/static/js/appauth.js | 41 ++-------
3 files changed, 109 insertions(+), 52 deletions(-)
create mode 100644 src/octoprint/plugins/appauth/static/clientjs/appauth.js
diff --git a/src/octoprint/plugins/appauth/__init__.py b/src/octoprint/plugins/appauth/__init__.py
index 08d0bcf6b..398f2005f 100644
--- a/src/octoprint/plugins/appauth/__init__.py
+++ b/src/octoprint/plugins/appauth/__init__.py
@@ -31,15 +31,14 @@ class PendingDecision(object):
class ReadyDecision(object):
- def __init__(self, app_id, app_token, user_id, api_key):
+ def __init__(self, app_id, app_token, user_id):
self.app_id = app_id
self.app_token = app_token
self.user_id = user_id
- self.api_key = api_key
@classmethod
- def for_pending(cls, pending, api_key):
- return cls(pending.app_id, pending.app_token, pending.user_id, api_key)
+ def for_pending(cls, pending, user_id):
+ return cls(pending.app_id, pending.app_token, user_id)
class ActiveKey(object):
@@ -70,7 +69,8 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
##-- AssetPlugin hooks
def get_assets(self):
- return dict(js=["js/appauth.js"])
+ return dict(js=["js/appauth.js"],
+ clientjs=["clientjs/appauth.js"])
##~~ BlueprintPlugin mixin
@@ -101,10 +101,12 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
@no_firstrun_access
def handle_decision_poll(self, app_token):
if self._is_pending(app_token):
- return flask.make_response("Awaiting decision", 202)
+ response = flask.jsonify(message="Awaiting decision")
+ response.status_code = 202
+ return response
result = self._get_decision(app_token)
- if result is not None:
+ if result:
return flask.jsonify(api_key=result)
return flask.abort(404)
@@ -159,11 +161,7 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
if not app_name:
return flask.abort(400)
- api_key = self._generate_key()
- try:
- self._add_api_key(user_id, app_name.trim(), api_key)
- except AppAlreadyExists:
- return flask.abort(409)
+ self._add_api_key(user_id, app_name.trim())
return NO_CONTENT
@@ -210,7 +208,7 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
if decision:
with self._ready_lock:
- self._ready_decisions.append(ReadyDecision.for_pending(pending, self._generate_key()))
+ self._ready_decisions.append(ReadyDecision.for_pending(pending, user_id))
with self._pending_lock:
self._pending_decisions = filter(lambda x: x.user_token != user_token, self._pending_decisions)
@@ -226,20 +224,23 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
else:
return False # not found
- self._add_api_key(decision.user_id, decision.app_id, decision.api_key)
+ api_key = self._add_api_key(decision.user_id, decision.app_id)
with self._ready_lock:
self._ready_decisions = filter(lambda x: x.app_token != app_token, self._ready_decisions)
- return decision.api_key
+ return api_key
- def _add_api_key(self, user_id, app_name, api_key):
+ def _add_api_key(self, user_id, app_name):
with self._keys_lock:
# TODO: persist to disk
for key in self._keys[user_id]:
if key.app_id.lower() == app_name.lower():
- raise AppAlreadyExists("app {} does already exist".format(app_name))
- self._keys[user_id].append(ActiveKey(app_name, api_key))
+ return key.api_key
+
+ key = ActiveKey(app_name, self._generate_key())
+ self._keys[user_id].append(key)
+ return key.api_key
def _delete_api_key(self, user_id, api_key):
with self._keys_lock:
diff --git a/src/octoprint/plugins/appauth/static/clientjs/appauth.js b/src/octoprint/plugins/appauth/static/clientjs/appauth.js
new file mode 100644
index 000000000..57800af43
--- /dev/null
+++ b/src/octoprint/plugins/appauth/static/clientjs/appauth.js
@@ -0,0 +1,83 @@
+(function (global, factory) {
+ if (typeof define === "function" && define.amd) {
+ define(["OctoPrintClient"], factory);
+ } else {
+ factory(global.OctoPrintClient);
+ }
+})(this, function(OctoPrintClient) {
+ var OctoPrintAppAuthClient = function(base) {
+ this.base = base;
+ };
+
+ OctoPrintAppAuthClient.prototype.getKeys = function(opts) {
+ return this.base.simpleApiGet("appauth", opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.generateKey = function(app, opts) {
+ return this.base.simpleApiCommand("appauth", "generate", {"app": app}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.revokeKey = function(key, opts) {
+ return this.base.simpleApiCommand("appauth", "revoke", {"key": key}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.decide = function(token, decision, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appauth") + "decision/" + token, {decision: !!decision}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.request = function(app, opts) {
+ return this.requestForUser(app, undefined, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.requestForUser = function(app, user, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appauth") + "request", {app: app, user: user}, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.checkDecision = function(token, opts) {
+ return this.base.get(this.base.getBlueprintUrl("appauth") + "request/" + token, opts);
+ };
+
+ OctoPrintAppAuthClient.prototype.authenticate = function(app, user) {
+ var deferred = $.Deferred();
+ var client = this;
+
+ client.requestForUser(app, user)
+ .done(function(response) {
+ var token = response.app_token;
+ if (!token) {
+ // no token received, something went wrong
+ deferred.reject();
+ return;
+ }
+
+ var interval = 1000;
+ var poll = function() {
+ client.checkDecision(token)
+ .done(function(response) {
+ if (response.api_key) {
+ // got a decision, resolve the promise
+ deferred.resolve(response.api_key);
+ } else {
+ // no decision yet, poll a bit more
+ deferred.notify();
+ window.setTimeout(poll, interval);
+ }
+ })
+ .fail(function() {
+ // something went wrong
+ deferred.reject();
+ });
+ };
+ window.setTimeout(poll, interval);
+ })
+ .fail(function() {
+ // something went wrong
+ deferred.reject();
+ });
+
+ return deferred.promise();
+ };
+
+ OctoPrintClient.registerPluginComponent("appauth", OctoPrintAppAuthClient);
+ return OctoPrintAppAuthClient;
+});
diff --git a/src/octoprint/plugins/appauth/static/js/appauth.js b/src/octoprint/plugins/appauth/static/js/appauth.js
index 74ec1e6e1..1cc353935 100644
--- a/src/octoprint/plugins/appauth/static/js/appauth.js
+++ b/src/octoprint/plugins/appauth/static/js/appauth.js
@@ -1,34 +1,3 @@
-(function (global, factory) {
- if (typeof define === "function" && define.amd) {
- define(["OctoPrintClient"], factory);
- } else {
- factory(global.OctoPrintClient);
- }
-})(this, function(OctoPrintClient) {
- var OctoPrintAppAuthClient = function(base) {
- this.base = base;
- };
-
- OctoPrintAppAuthClient.prototype.getKeys = function(opts) {
- return this.base.simpleApiGet("appauth", opts);
- };
-
- OctoPrintAppAuthClient.prototype.generateKey = function(app, opts) {
- return this.base.simpleApiCommand("appauth", "generate", {"app": app}, opts);
- };
-
- OctoPrintAppAuthClient.prototype.revokeKey = function(key, opts) {
- return this.base.simpleApiCommand("appauth", "revoke", {"key": key}, opts);
- };
-
- OctoPrintAppAuthClient.prototype.decide = function(token, decision, opts) {
- return this.base.postJson(this.base.getBlueprintUrl("appauth") + "decision/" + token, {decision: !!decision}, opts);
- };
-
- OctoPrintClient.registerPluginComponent("appauth", OctoPrintAppAuthClient);
- return OctoPrintAppAuthClient;
-});
-
$(function() {
function AppAuthViewModel(parameters) {
var self = this;
@@ -90,23 +59,27 @@ $(function() {
};
self.promptForAccess = function(app, token) {
- var message = gettext("\"%(app)s\" has requested access to control OctoPrint through the API. Do you want to allow access to this application with your user account?");
+ var message = gettext("\"%(app)s \" has requested access to control OctoPrint through the API.");
message = _.sprintf(message, {app: app});
-
+ message = "" + message + "
" + gettext("Do you want to allow access to this application with your user account?") + "
";
return new PNotify({
title: gettext("Access Request"),
text: message,
+ hide: false,
+ icon: "fa fa-key",
confirm: {
confirm: true,
buttons: [{
text: gettext("Allow"),
click: function(notice) {
self.allowApp(token);
+ notice.remove();
}
}, {
text: gettext("Deny"),
click: function(notice) {
self.denyApp(token);
+ notice.remove();
}
}]
},
@@ -141,7 +114,7 @@ $(function() {
return;
}
- if (self.pending[token] === undefined) {
+ if (self.pending[token] !== undefined) {
return;
}
From d6c63a5cb9904a4510833407093fc5e1eac5ab80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 31 Aug 2018 20:22:40 +0200
Subject: [PATCH 020/183] appauth -> appkeys
---
.../templates/appauth_usersettings.jinja2 | 42 ----------------
.../plugins/{appauth => appkeys}/__init__.py | 22 ++++++---
.../static/clientjs/appkeys.js} | 34 ++++++-------
.../plugins/appkeys/static/css/appkeys.css | 1 +
.../static/js/appkeys.js} | 20 ++++----
.../plugins/appkeys/static/less/appkeys.less | 12 +++++
.../templates/appkeys_usersettings.jinja2 | 49 +++++++++++++++++++
7 files changed, 104 insertions(+), 76 deletions(-)
delete mode 100644 src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
rename src/octoprint/plugins/{appauth => appkeys}/__init__.py (92%)
rename src/octoprint/plugins/{appauth/static/clientjs/appauth.js => appkeys/static/clientjs/appkeys.js} (66%)
create mode 100644 src/octoprint/plugins/appkeys/static/css/appkeys.css
rename src/octoprint/plugins/{appauth/static/js/appauth.js => appkeys/static/js/appkeys.js} (89%)
create mode 100644 src/octoprint/plugins/appkeys/static/less/appkeys.less
create mode 100644 src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
diff --git a/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2 b/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
deleted file mode 100644
index aeb2f9e67..000000000
--- a/src/octoprint/plugins/appauth/templates/appauth_usersettings.jinja2
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- {{ _('Application') }}
- {{ _('Action') }}
-
-
-
-
- {{ _('API Key') }}:
-
-
-
-
-
-
-
-
-
diff --git a/src/octoprint/plugins/appauth/__init__.py b/src/octoprint/plugins/appkeys/__init__.py
similarity index 92%
rename from src/octoprint/plugins/appauth/__init__.py
rename to src/octoprint/plugins/appkeys/__init__.py
index 398f2005f..27c261b69 100644
--- a/src/octoprint/plugins/appauth/__init__.py
+++ b/src/octoprint/plugins/appkeys/__init__.py
@@ -6,6 +6,7 @@ import threading
import os
from binascii import hexlify
from collections import defaultdict
+from flask_babel import gettext
import octoprint.plugin
from octoprint.settings import valid_boolean_trues
@@ -51,7 +52,7 @@ class ActiveKey(object):
api_key=self.api_key)
-class AppAuthPlugin(octoprint.plugin.AssetPlugin,
+class AppKeysPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.BlueprintPlugin,
octoprint.plugin.SimpleApiPlugin,
octoprint.plugin.TemplatePlugin):
@@ -66,11 +67,18 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
self._keys = defaultdict(list)
self._keys_lock = threading.RLock()
- ##-- AssetPlugin hooks
+ ##~~ TemplatePlugin
+
+ def get_template_configs(self):
+ return [dict(type="usersettings", name=gettext("Application Keys"), custom_bindings=False)]
+
+ ##~~ AssetPlugin
def get_assets(self):
- return dict(js=["js/appauth.js"],
- clientjs=["clientjs/appauth.js"])
+ return dict(js=["js/appkeys.js"],
+ clientjs=["clientjs/appkeys.js"],
+ less=["less/appkeys.less"],
+ css=["css/appkeys.css"])
##~~ BlueprintPlugin mixin
@@ -161,7 +169,7 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
if not app_name:
return flask.abort(400)
- self._add_api_key(user_id, app_name.trim())
+ self._add_api_key(user_id, app_name.strip())
return NO_CONTENT
@@ -261,10 +269,10 @@ class AppAuthPlugin(octoprint.plugin.AssetPlugin,
def _generate_key(self):
return hexlify(os.urandom(16))
-__plugin_name__ = "AppAuth Plugin"
+__plugin_name__ = "Application Keys Plugin"
__plugin_description__ = "TODO"
__plugin_author__ = "Gina Häußge, Aldo Hoeben"
-__plugin_implementation__ = AppAuthPlugin()
+__plugin_implementation__ = AppKeysPlugin()
__plugin_hooks__ = {
"octoprint.accesscontrol.keyvalidator": __plugin_implementation__.validate_api_key
}
diff --git a/src/octoprint/plugins/appauth/static/clientjs/appauth.js b/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
similarity index 66%
rename from src/octoprint/plugins/appauth/static/clientjs/appauth.js
rename to src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
index 57800af43..1e70f4b89 100644
--- a/src/octoprint/plugins/appauth/static/clientjs/appauth.js
+++ b/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
@@ -5,39 +5,39 @@
factory(global.OctoPrintClient);
}
})(this, function(OctoPrintClient) {
- var OctoPrintAppAuthClient = function(base) {
+ var OctoPrintAppKeysClient = function(base) {
this.base = base;
};
- OctoPrintAppAuthClient.prototype.getKeys = function(opts) {
- return this.base.simpleApiGet("appauth", opts);
+ OctoPrintAppKeysClient.prototype.getKeys = function(opts) {
+ return this.base.simpleApiGet("appkeys", opts);
};
- OctoPrintAppAuthClient.prototype.generateKey = function(app, opts) {
- return this.base.simpleApiCommand("appauth", "generate", {"app": app}, opts);
+ OctoPrintAppKeysClient.prototype.generateKey = function(app, opts) {
+ return this.base.simpleApiCommand("appkeys", "generate", {"app": app}, opts);
};
- OctoPrintAppAuthClient.prototype.revokeKey = function(key, opts) {
- return this.base.simpleApiCommand("appauth", "revoke", {"key": key}, opts);
+ OctoPrintAppKeysClient.prototype.revokeKey = function(key, opts) {
+ return this.base.simpleApiCommand("appkeys", "revoke", {"key": key}, opts);
};
- OctoPrintAppAuthClient.prototype.decide = function(token, decision, opts) {
- return this.base.postJson(this.base.getBlueprintUrl("appauth") + "decision/" + token, {decision: !!decision}, opts);
+ OctoPrintAppKeysClient.prototype.decide = function(token, decision, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appkeys") + "decision/" + token, {decision: !!decision}, opts);
};
- OctoPrintAppAuthClient.prototype.request = function(app, opts) {
+ OctoPrintAppKeysClient.prototype.request = function(app, opts) {
return this.requestForUser(app, undefined, opts);
};
- OctoPrintAppAuthClient.prototype.requestForUser = function(app, user, opts) {
- return this.base.postJson(this.base.getBlueprintUrl("appauth") + "request", {app: app, user: user}, opts);
+ OctoPrintAppKeysClient.prototype.requestForUser = function(app, user, opts) {
+ return this.base.postJson(this.base.getBlueprintUrl("appkeys") + "request", {app: app, user: user}, opts);
};
- OctoPrintAppAuthClient.prototype.checkDecision = function(token, opts) {
- return this.base.get(this.base.getBlueprintUrl("appauth") + "request/" + token, opts);
+ OctoPrintAppKeysClient.prototype.checkDecision = function(token, opts) {
+ return this.base.get(this.base.getBlueprintUrl("appkeys") + "request/" + token, opts);
};
- OctoPrintAppAuthClient.prototype.authenticate = function(app, user) {
+ OctoPrintAppKeysClient.prototype.authenticate = function(app, user) {
var deferred = $.Deferred();
var client = this;
@@ -78,6 +78,6 @@
return deferred.promise();
};
- OctoPrintClient.registerPluginComponent("appauth", OctoPrintAppAuthClient);
- return OctoPrintAppAuthClient;
+ OctoPrintClient.registerPluginComponent("appkeys", OctoPrintAppKeysClient);
+ return OctoPrintAppKeysClient;
});
diff --git a/src/octoprint/plugins/appkeys/static/css/appkeys.css b/src/octoprint/plugins/appkeys/static/css/appkeys.css
new file mode 100644
index 000000000..20673bafa
--- /dev/null
+++ b/src/octoprint/plugins/appkeys/static/css/appkeys.css
@@ -0,0 +1 @@
+#settings_plugin_appauth_keys_table .settings_plugin_appauth_keys_actions{width:75px;text-align:center}#settings_plugin_appauth_keys_table .settings_plugin_appauth_keys_actions a{color:#000}
\ No newline at end of file
diff --git a/src/octoprint/plugins/appauth/static/js/appauth.js b/src/octoprint/plugins/appkeys/static/js/appkeys.js
similarity index 89%
rename from src/octoprint/plugins/appauth/static/js/appauth.js
rename to src/octoprint/plugins/appkeys/static/js/appkeys.js
index 1cc353935..015493f8f 100644
--- a/src/octoprint/plugins/appauth/static/js/appauth.js
+++ b/src/octoprint/plugins/appkeys/static/js/appkeys.js
@@ -1,10 +1,10 @@
$(function() {
- function AppAuthViewModel(parameters) {
+ function AppKeysViewModel(parameters) {
var self = this;
self.loginState = parameters[0];
self.keys = new ItemListHelper(
- "plugin.appauth.keys",
+ "plugin.appkeys.keys",
{
"app": function (a, b) {
// sorts descending
@@ -26,7 +26,7 @@ $(function() {
self.editorApp = ko.observable();
self.requestData = function() {
- OctoPrint.plugins.appauth.getKeys()
+ OctoPrint.plugins.appkeys.getKeys()
.done(self.fromResponse);
};
@@ -39,22 +39,22 @@ $(function() {
};
self.generateKey = function() {
- return OctoPrint.plugins.appauth.generateKey(self.editorApp())
+ return OctoPrint.plugins.appkeys.generateKey(self.editorApp())
.done(self.requestData);
};
self.revokeKey = function(key) {
- return OctoPrint.plugins.appauth.revokeKey(key)
+ return OctoPrint.plugins.appkeys.revokeKey(key)
.done(self.requestData);
};
self.allowApp = function(token) {
- return OctoPrint.plugins.appauth.decide(token, true)
+ return OctoPrint.plugins.appkeys.decide(token, true)
.done(self.requestData);
};
self.denyApp = function(token) {
- return OctoPrint.plugins.appauth.decide(token, false)
+ return OctoPrint.plugins.appkeys.decide(token, false)
.done(self.requestData);
};
@@ -99,7 +99,7 @@ $(function() {
};
self.onDataUpdaterPluginMessage = function(plugin, data) {
- if (plugin !== "appauth") {
+ if (plugin !== "appkeys") {
return;
}
@@ -135,8 +135,8 @@ $(function() {
}
OCTOPRINT_VIEWMODELS.push([
- AppAuthViewModel,
+ AppKeysViewModel,
["loginStateViewModel"],
- ["#usersettings_plugin_appauth"]
+ ["#usersettings_plugin_appkeys"]
]);
});
diff --git a/src/octoprint/plugins/appkeys/static/less/appkeys.less b/src/octoprint/plugins/appkeys/static/less/appkeys.less
new file mode 100644
index 000000000..1b871993f
--- /dev/null
+++ b/src/octoprint/plugins/appkeys/static/less/appkeys.less
@@ -0,0 +1,12 @@
+#settings_plugin_appauth_keys_table {
+ .settings_plugin_appauth_keys_app {
+ }
+ .settings_plugin_appauth_keys_actions {
+ width: 75px;
+ text-align: center;
+
+ a {
+ color: black;
+ }
+ }
+}
diff --git a/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2 b/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
new file mode 100644
index 000000000..0eae9334d
--- /dev/null
+++ b/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
@@ -0,0 +1,49 @@
+{{ _('Registered application keys') }}
+
+
+
{{ _('There are no application keys registered yet.') }}
+
+
+
+
+
+ {{ _('Application identifier') }}
+ {{ _('Action') }}
+
+
+
+
+ {{ _('API Key') }}:
+
+
+
+
+
+
+
+{{ _('Manually generate an application key') }}
+
+
From 3fe2b611bc24343f987a1dede555e68f1c114c08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 31 Aug 2018 20:35:16 +0200
Subject: [PATCH 021/183] Appkeys: fix template config
---
src/octoprint/plugins/appkeys/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py
index 27c261b69..91b0ca960 100644
--- a/src/octoprint/plugins/appkeys/__init__.py
+++ b/src/octoprint/plugins/appkeys/__init__.py
@@ -70,7 +70,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
##~~ TemplatePlugin
def get_template_configs(self):
- return [dict(type="usersettings", name=gettext("Application Keys"), custom_bindings=False)]
+ return [dict(type="usersettings", name=gettext("Application Keys"))]
##~~ AssetPlugin
From 257fc0d1cdf16949582f95ef09be59aa48587278 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 31 Aug 2018 20:45:16 +0200
Subject: [PATCH 022/183] Appkeys: allow fetching of all keys
Also added TODO list ;)
---
src/octoprint/plugins/appkeys/__init__.py | 35 ++++++++++++++++---
.../appkeys/static/clientjs/appkeys.js | 4 +++
2 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py
index 91b0ca960..2666047b9 100644
--- a/src/octoprint/plugins/appkeys/__init__.py
+++ b/src/octoprint/plugins/appkeys/__init__.py
@@ -11,7 +11,18 @@ from flask_babel import gettext
import octoprint.plugin
from octoprint.settings import valid_boolean_trues
from octoprint.server.util.flask import restricted_access, no_firstrun_access
-from octoprint.server import NO_CONTENT, current_user, user_permission
+from octoprint.server import NO_CONTENT, current_user, admin_permission
+
+
+"""
+TODO:
+ * add key persistence
+ * add central management settings panel for *all* user's keys
+ * bulk delete: delete all, all on page, all by user?
+ * write documentation
+ * API docs
+ * JS client docs
+"""
class AppAlreadyExists(Exception):
@@ -43,13 +54,15 @@ class ReadyDecision(object):
class ActiveKey(object):
- def __init__(self, app_id, api_key):
+ def __init__(self, app_id, api_key, user_id):
self.app_id = app_id
self.api_key = api_key
+ self.user_id = user_id
def external(self):
return dict(app_id=self.app_id,
- api_key=self.api_key)
+ api_key=self.api_key,
+ user_id=self.user_id)
class AppKeysPlugin(octoprint.plugin.AssetPlugin,
@@ -148,7 +161,12 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
if not user_id:
return flask.abort(403)
- return flask.jsonify(keys=map(lambda x: x.external(), self._api_keys_for_user(user_id)),
+ if request.values.get("all") in valid_boolean_trues and admin_permission.can():
+ keys = self._all_api_keys()
+ else:
+ keys = self._api_keys_for_user(user_id)
+
+ return flask.jsonify(keys=map(lambda x: x.external(), keys),
pending=dict((x.user_token, x.external()) for x in self._get_pending(user_id)))
def on_api_command(self, command, data):
@@ -246,7 +264,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
if key.app_id.lower() == app_name.lower():
return key.api_key
- key = ActiveKey(app_name, self._generate_key())
+ key = ActiveKey(app_name, self._generate_key(), user_id)
self._keys[user_id].append(key)
return key.api_key
@@ -266,6 +284,13 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
with self._keys_lock:
return self._keys.get(user_id, [])
+ def _all_api_keys(self):
+ with self._keys_lock:
+ result = []
+ for user_id, keys in self._keys.items():
+ result += keys
+ return result
+
def _generate_key(self):
return hexlify(os.urandom(16))
diff --git a/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js b/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
index 1e70f4b89..580ad1364 100644
--- a/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
+++ b/src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
@@ -13,6 +13,10 @@
return this.base.simpleApiGet("appkeys", opts);
};
+ OctoPrintAppKeysClient.prototype.getAllKeys = function(opts) {
+ return this.base.get(OctoPrintClient.prototype.getSimpleApiUrl("appkeys") + "?all=true", opts);
+ };
+
OctoPrintAppKeysClient.prototype.generateKey = function(app, opts) {
return this.base.simpleApiCommand("appkeys", "generate", {"app": app}, opts);
};
From b0e7df47a69b4527932a26fbcdc4185203ff41c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Mon, 3 Sep 2018 18:38:36 +0200
Subject: [PATCH 023/183] Appkeys: Add key persistence
---
src/octoprint/plugins/appkeys/__init__.py | 54 ++++++++++++++++++++++-
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py
index 2666047b9..5f491db96 100644
--- a/src/octoprint/plugins/appkeys/__init__.py
+++ b/src/octoprint/plugins/appkeys/__init__.py
@@ -4,6 +4,9 @@ from __future__ import absolute_import
import flask
import threading
import os
+import yaml
+import codecs
+import time
from binascii import hexlify
from collections import defaultdict
from flask_babel import gettext
@@ -12,6 +15,7 @@ import octoprint.plugin
from octoprint.settings import valid_boolean_trues
from octoprint.server.util.flask import restricted_access, no_firstrun_access
from octoprint.server import NO_CONTENT, current_user, admin_permission
+from octoprint.util import atomic_write
"""
@@ -64,6 +68,14 @@ class ActiveKey(object):
api_key=self.api_key,
user_id=self.user_id)
+ def internal(self):
+ return dict(app_id=self.app_id,
+ api_key=self.api_key)
+
+ @classmethod
+ def for_internal(cls, internal, user_id):
+ return cls(internal["app_id"], internal["api_key"], user_id)
+
class AppKeysPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.BlueprintPlugin,
@@ -80,6 +92,12 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
self._keys = defaultdict(list)
self._keys_lock = threading.RLock()
+ self._key_path = None
+
+ def initialize(self):
+ self._key_path = os.path.join(self.get_plugin_data_folder(), "keys.yaml")
+ self._load_keys()
+
##~~ TemplatePlugin
def get_template_configs(self):
@@ -259,19 +277,19 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
def _add_api_key(self, user_id, app_name):
with self._keys_lock:
- # TODO: persist to disk
for key in self._keys[user_id]:
if key.app_id.lower() == app_name.lower():
return key.api_key
key = ActiveKey(app_name, self._generate_key(), user_id)
self._keys[user_id].append(key)
+ self._save_keys()
return key.api_key
def _delete_api_key(self, user_id, api_key):
with self._keys_lock:
- # TODO: persist to disk
self._keys[user_id] = filter(lambda x: x.api_key != api_key, self._keys[user_id])
+ self._save_keys()
def _user_for_api_key(self, api_key):
with self._keys_lock:
@@ -294,6 +312,38 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
def _generate_key(self):
return hexlify(os.urandom(16))
+ def _load_keys(self):
+ with self._keys_lock:
+ if not os.path.exists(self._key_path):
+ return
+
+ try:
+ with codecs.open(self._key_path, "rb", encoding="utf-8", errors="strict") as f:
+ persisted = yaml.safe_load(f)
+ except:
+ self._logger.exception("Could not load application keys from {}".format(self._key_path))
+ return
+
+ if not isinstance(persisted, dict):
+ return
+
+ keys = dict()
+ for user_id, persisted_keys in persisted.items():
+ keys[user_id] = [ActiveKey.for_internal(x, user_id) for x in persisted_keys]
+ self._keys = keys
+
+ def _save_keys(self):
+ with self._keys_lock:
+ to_persist = dict()
+ for user_id, keys in self._keys.items():
+ to_persist[user_id] = [x.internal() for x in keys]
+
+ try:
+ with atomic_write(self._key_path) as f:
+ yaml.safe_dump(to_persist, f)
+ except:
+ self._logger.exception("Could not write application keys to {}".format(self._key_path))
+
__plugin_name__ = "Application Keys Plugin"
__plugin_description__ = "TODO"
__plugin_author__ = "Gina Häußge, Aldo Hoeben"
From e95e546c0882e74075a73e84be328bc084712cd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Mon, 15 Oct 2018 12:48:41 +0200
Subject: [PATCH 024/183] Appkey: Copy key to clipboard
---
src/octoprint/plugins/appkeys/__init__.py | 1 -
.../plugins/appkeys/templates/appkeys_usersettings.jinja2 | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py
index 5f491db96..d61f5ed8f 100644
--- a/src/octoprint/plugins/appkeys/__init__.py
+++ b/src/octoprint/plugins/appkeys/__init__.py
@@ -20,7 +20,6 @@ from octoprint.util import atomic_write
"""
TODO:
- * add key persistence
* add central management settings panel for *all* user's keys
* bulk delete: delete all, all on page, all by user?
* write documentation
diff --git a/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2 b/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
index 0eae9334d..c2472ff2a 100644
--- a/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
+++ b/src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
@@ -13,7 +13,7 @@
- {{ _('API Key') }}:
+ {{ _('API Key') }}:
From 7b5d2e3e0c3c09e0f0d419bb428e8c01baa3f820 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Thu, 18 Oct 2018 17:32:32 +0200
Subject: [PATCH 025/183] Allow whitespace after : in M114 responses
Closes #2839
---
src/octoprint/util/comm.py | 4 ++--
tests/util/test_comm_helpers.py | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py
index bee3e0837..68ffbf039 100644
--- a/src/octoprint/util/comm.py
+++ b/src/octoprint/util/comm.py
@@ -126,7 +126,7 @@ Groups will be as follows:
* ``target``: new target temperature (float)
"""
-regex_position = re.compile("X:(?P{float})\s*Y:(?P{float})\s*Z:(?P{float})\s*((E:(?P{float}))|(?P(E\d+:{float}\s*)+))".format(float=regex_float_pattern))
+regex_position = re.compile("X:\s*(?P{float})\s*Y:\s*(?P{float})\s*Z:\s*(?P{float})\s*((E:\s*(?P{float}))|(?P(E\d+:\s*{float}\s*)+))".format(float=regex_float_pattern))
"""Regex for matching position reporting.
Groups will be as follows:
@@ -138,7 +138,7 @@ Groups will be as follows:
* ``es``: multiple E coordinates if present, to be parsed further with regex_e_positions
"""
-regex_e_positions = re.compile("E(?P\d+):(?P{float})".format(float=regex_float_pattern))
+regex_e_positions = re.compile("E(?P\d+):\s*(?P{float})".format(float=regex_float_pattern))
"""Regex for matching multiple E coordinates in a position report.
Groups will be as follows:
diff --git a/tests/util/test_comm_helpers.py b/tests/util/test_comm_helpers.py
index 119ff406d..1524dbd99 100644
--- a/tests/util/test_comm_helpers.py
+++ b/tests/util/test_comm_helpers.py
@@ -333,6 +333,12 @@ class TestCommHelpers(unittest.TestCase):
e4=0.0,
e5=0.0)),
+ # whitespace after the :, e.g. AlfaWise U20, see #2839
+ ("X:150.0 Y:150.0 Z: 0.7 E: 0.0", dict(x=150.0,
+ y=150.0,
+ z=0.7,
+ e=0.0)),
+
# invalid
("", None),
("X:62.417 Y:64.781 Z:0.2", None)
From ac2354907a5b55d94e256d9de7bf63452ed46085 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Thu, 18 Oct 2018 17:33:08 +0200
Subject: [PATCH 026/183] Remove some trailing whitespace
---
tests/util/test_comm_helpers.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/util/test_comm_helpers.py b/tests/util/test_comm_helpers.py
index 1524dbd99..dc3adae14 100644
--- a/tests/util/test_comm_helpers.py
+++ b/tests/util/test_comm_helpers.py
@@ -267,11 +267,11 @@ class TestCommHelpers(unittest.TestCase):
("NAME. Malyan VER: 3.7 MODEL: M300 HW: HG01",
dict(NAME="Malyan", VER="3.7", MODEL="M300", HW="HG01")),
("FIRMWARE_NAME:Marlin 1.1.0 From Archive SOURCE_CODE_URL:http:// ... PROTOCOL_VERSION:1.0 MACHINE_TYPE:www.cxsw3d.com EXTRUDER_COUNT:1 UUID:00000000-0000-0000-0000-000000000000",
- dict(FIRMWARE_NAME="Marlin 1.1.0 From Archive",
- SOURCE_CODE_URL="http:// ...",
- PROTOCOL_VERSION="1.0",
- MACHINE_TYPE="www.cxsw3d.com",
- EXTRUDER_COUNT="1",
+ dict(FIRMWARE_NAME="Marlin 1.1.0 From Archive",
+ SOURCE_CODE_URL="http:// ...",
+ PROTOCOL_VERSION="1.0",
+ MACHINE_TYPE="www.cxsw3d.com",
+ EXTRUDER_COUNT="1",
UUID="00000000-0000-0000-0000-000000000000"))
)
@unpack
From 025986794fbb84039f0f32fcd3eef83678d2792e Mon Sep 17 00:00:00 2001
From: Eyal Soha
Date: Thu, 11 Oct 2018 10:21:08 -0400
Subject: [PATCH 027/183] Remove requirement to have messages.pot to use
babel_extract
---
src/octoprint_setuptools/__init__.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/octoprint_setuptools/__init__.py b/src/octoprint_setuptools/__init__.py
index 328be4558..158408a53 100644
--- a/src/octoprint_setuptools/__init__.py
+++ b/src/octoprint_setuptools/__init__.py
@@ -524,8 +524,7 @@ def create_plugin_setup_parameters(identifier="todo", name="TODO", version="0.1"
translation_dir = os.path.join(source_folder, "translations")
pot_file = os.path.join(translation_dir, "messages.pot")
bundled_dir = os.path.join(source_folder, package, "translations")
- if os.path.isdir(translation_dir) and os.path.isfile(pot_file):
- cmdclass.update(get_babel_commandclasses(pot_file=pot_file, output_dir=translation_dir, bundled_dir=bundled_dir, pack_name_prefix="{name}-i18n-".format(**locals()), pack_path_prefix="_plugins/{identifier}/".format(**locals())))
+ cmdclass.update(get_babel_commandclasses(pot_file=pot_file, output_dir=translation_dir, bundled_dir=bundled_dir, pack_name_prefix="{name}-i18n-".format(**locals()), pack_path_prefix="_plugins/{identifier}/".format(**locals())))
from setuptools import find_packages
packages = list(set([package] + filter(lambda x: x.startswith("{package}.".format(package=package)), find_packages(where=source_folder, exclude=ignored_packages)) + additional_packages))
From 108db045cec69bdb71c724ed4b3811f8c034c7f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Thu, 18 Oct 2018 18:06:01 +0200
Subject: [PATCH 028/183] Small changes to the contribution guidelines
* allow PRs against `maintenance` branch for improvements and small
new features
* suggest getting in touch on the forum for larger changes
---
CONTRIBUTING.md | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 861215f4d..e4321207d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -27,7 +27,7 @@ to **address problems in a timely manner** but also keep it possible for them
to **fix bugs, add new and improve on existing functionality** instead of doing
nothing but ticket management.
-
+
- **[Read the FAQ](https://faq.octoprint.org)**
- If you want to report a **bug**, [read "How to file a bug report" below](#how-to-file-a-bug-report)
@@ -301,7 +301,8 @@ the documentation.
the discussion going on how best to solve *this* in OctoPrint's plugin
system - maybe that's the actual PR you have been waiting for to contribute :)
2. If you plan to make **any large or otherwise disruptive changes to the
- code or appearance, please open a "Brainstorming" ticket first** so
+ code or appearance, please get in touch on the
+ [forums](https://discourse.octoprint.org/c/development)** first so
that we can determine if it's a good time for your specific pull
request. It might be that we're currently in the process of making
heavy changes to the code locations you'd target as well, or your
@@ -311,7 +312,8 @@ the documentation.
3. Create your pull request **from a custom branch** on your end (e.g.
`dev/myNewFeature`)[1].
4. Create your pull request **only against the `maintenance` or `devel` branch**:
- * if it's a bug fix for a bug in the current stable version: `maintenance` branch
+ * if it's a bug fix for a bug in the current stable version, an improvement of existing functionality or a
+ *small* new feature (e.g. a new hook, a new config flag, ...): `maintenance` branch
* otherwise: `devel` branch
5. Create **one pull request per feature/bug fix**.
6. Make sure there are **only relevant changes** included in your PR. No
@@ -472,7 +474,9 @@ the local version identifier to allow for an exact determination of the active c
* 2017-11-22: Added note on how to run the unit tests
* 2018-03-15: Link to new community forum and some clarifications re bug
reporting
- * 2018-03-29: "Where to find version numbers" is now located on the FAQ
+ * 2018-03-29: "Where to find version numbers" is now located on the FAQ
+ * 2018-10-18: Allow PRs against `maintenance` branch for improvements and small
+ new features, suggest getting in touch on the forum for larger changes
## Footnotes
* [1] - If you are wondering why, the problem is that anything that you add
From 2f89082df21d37aab22553643ddab3c8000b8cf3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 19 Oct 2018 13:14:31 +0200
Subject: [PATCH 029/183] Missed something in yesterday's changes to contrib
guide
---
CONTRIBUTING.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e4321207d..97299046d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -39,11 +39,11 @@ nothing but ticket management.
[community forum at discourse.octoprint.org](https://discourse.octoprint.org) for
such support issues.
- If you are a **developer** that wants to brainstorm a pull request or possible
- changes to the plugin system, add [Brainstorming] to your issue's title (e.g.
- `[Brainstorming] New plugin hook for doing some cool stuff`).
+ changes to the plugin system, please get in touch on the
+ [community forum at discourse.octoprint.org](https://discourse.octoprint.org/c/development).
- If you need **support**, have a **question** or some **other reason** that
doesn't fit any of the above categories, the issue tracker is not the right place.
- Consult the [community forum at discourse.octoprint.org](https://discourse.octoprint.org) instead.
+ Consult the [community forum at discourse.octoprint.org](https://discourse.octoprint.org/c/support) instead.
No matter what kind of ticket you create, never mix two or more "ticket reasons"
into one ticket: One ticket per bug, request, brainstorming thread please.
@@ -53,7 +53,7 @@ into one ticket: One ticket per bug, request, brainstorming thread please.
> A bot is in place that monitors new tickets, automatically
> categorizes them and checks new bug reports for usage of the provided template.
> That bot will only bother you if you open a ticket that appears to be a bug (no
-> `[Request]` or `[Brainstorming]` in the title) without the complete template, and it
+> `[Request]` in the title) without the complete template, and it
> will do that only to ensure that all information needed to solve the issue is
> available for the maintainers to directly start tackling that problem.
From df8226b8c5bdc2a38cf82fd09586790fbf2c915c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Thu, 18 Oct 2018 18:06:01 +0200
Subject: [PATCH 030/183] Small changes to the contribution guidelines
* allow PRs against `maintenance` branch for improvements and small
new features
* suggest getting in touch on the forum for larger changes
---
CONTRIBUTING.md | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 861215f4d..e4321207d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -27,7 +27,7 @@ to **address problems in a timely manner** but also keep it possible for them
to **fix bugs, add new and improve on existing functionality** instead of doing
nothing but ticket management.
-
+
- **[Read the FAQ](https://faq.octoprint.org)**
- If you want to report a **bug**, [read "How to file a bug report" below](#how-to-file-a-bug-report)
@@ -301,7 +301,8 @@ the documentation.
the discussion going on how best to solve *this* in OctoPrint's plugin
system - maybe that's the actual PR you have been waiting for to contribute :)
2. If you plan to make **any large or otherwise disruptive changes to the
- code or appearance, please open a "Brainstorming" ticket first** so
+ code or appearance, please get in touch on the
+ [forums](https://discourse.octoprint.org/c/development)** first so
that we can determine if it's a good time for your specific pull
request. It might be that we're currently in the process of making
heavy changes to the code locations you'd target as well, or your
@@ -311,7 +312,8 @@ the documentation.
3. Create your pull request **from a custom branch** on your end (e.g.
`dev/myNewFeature`)[1].
4. Create your pull request **only against the `maintenance` or `devel` branch**:
- * if it's a bug fix for a bug in the current stable version: `maintenance` branch
+ * if it's a bug fix for a bug in the current stable version, an improvement of existing functionality or a
+ *small* new feature (e.g. a new hook, a new config flag, ...): `maintenance` branch
* otherwise: `devel` branch
5. Create **one pull request per feature/bug fix**.
6. Make sure there are **only relevant changes** included in your PR. No
@@ -472,7 +474,9 @@ the local version identifier to allow for an exact determination of the active c
* 2017-11-22: Added note on how to run the unit tests
* 2018-03-15: Link to new community forum and some clarifications re bug
reporting
- * 2018-03-29: "Where to find version numbers" is now located on the FAQ
+ * 2018-03-29: "Where to find version numbers" is now located on the FAQ
+ * 2018-10-18: Allow PRs against `maintenance` branch for improvements and small
+ new features, suggest getting in touch on the forum for larger changes
## Footnotes
* [1] - If you are wondering why, the problem is that anything that you add
From e57c46fb67c50a7e9a1ea76842da88d480d54d8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 19 Oct 2018 13:14:31 +0200
Subject: [PATCH 031/183] Missed something in yesterday's changes to contrib
guide
---
CONTRIBUTING.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e4321207d..97299046d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -39,11 +39,11 @@ nothing but ticket management.
[community forum at discourse.octoprint.org](https://discourse.octoprint.org) for
such support issues.
- If you are a **developer** that wants to brainstorm a pull request or possible
- changes to the plugin system, add [Brainstorming] to your issue's title (e.g.
- `[Brainstorming] New plugin hook for doing some cool stuff`).
+ changes to the plugin system, please get in touch on the
+ [community forum at discourse.octoprint.org](https://discourse.octoprint.org/c/development).
- If you need **support**, have a **question** or some **other reason** that
doesn't fit any of the above categories, the issue tracker is not the right place.
- Consult the [community forum at discourse.octoprint.org](https://discourse.octoprint.org) instead.
+ Consult the [community forum at discourse.octoprint.org](https://discourse.octoprint.org/c/support) instead.
No matter what kind of ticket you create, never mix two or more "ticket reasons"
into one ticket: One ticket per bug, request, brainstorming thread please.
@@ -53,7 +53,7 @@ into one ticket: One ticket per bug, request, brainstorming thread please.
> A bot is in place that monitors new tickets, automatically
> categorizes them and checks new bug reports for usage of the provided template.
> That bot will only bother you if you open a ticket that appears to be a bug (no
-> `[Request]` or `[Brainstorming]` in the title) without the complete template, and it
+> `[Request]` in the title) without the complete template, and it
> will do that only to ensure that all information needed to solve the issue is
> available for the maintainers to directly start tackling that problem.
From 36b07b2337be96ca665429a3e81b2602da3bddce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 19 Oct 2018 13:58:37 +0200
Subject: [PATCH 032/183] discovery: enumerate zeroconf service names on
collision
Fixes #2852
---
src/octoprint/plugins/discovery/__init__.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/octoprint/plugins/discovery/__init__.py b/src/octoprint/plugins/discovery/__init__.py
index 031ef7d48..90e50cc15 100644
--- a/src/octoprint/plugins/discovery/__init__.py
+++ b/src/octoprint/plugins/discovery/__init__.py
@@ -194,8 +194,20 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin,
params["txtRecord"] = pybonjour.TXTRecord(txt_record)
key = (reg_type, port)
- self._sd_refs[key] = pybonjour.DNSServiceRegister(**params)
- self._logger.info(u"Registered {name} for {reg_type}".format(**locals()))
+
+ counter = 0
+ while True:
+ try:
+ self._sd_refs[key] = pybonjour.DNSServiceRegister(**params)
+ self._logger.info(u"Registered '{name}' for {regtype}".format(**params))
+ return True
+ except pybonjour.BonjourError as be:
+ if be.errorCode == pybonjour.kDNSServiceErr_NameConflict:
+ # Name already registered by different service, let's try a counter postfix. See #2852
+ counter += 1
+ params["name"] = u"{} ({})".format(name, counter)
+ else:
+ raise
def zeroconf_unregister(self, reg_type, port=None):
"""
From 9e48b8ab65ad046dbddf513bce8ec9c34f74b2cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 19 Oct 2018 14:12:53 +0200
Subject: [PATCH 033/183] make sure to strip comments from address
---
src/octoprint/util/net.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/octoprint/util/net.py b/src/octoprint/util/net.py
index 05106ac74..494102887 100644
--- a/src/octoprint/util/net.py
+++ b/src/octoprint/util/net.py
@@ -45,7 +45,12 @@ def is_lan_address(address, additional_private=None):
if "/" in prefix:
# v6 notation in netifaces output, e.g. "ffff:ffff:ffff:ffff::/64"
_, prefix = prefix.split("/")
- return netaddr.IPNetwork("{}/{}".format(address["addr"], prefix))
+
+ addr = address["addr"]
+ if "%" in addr:
+ # interface comment in netifaces output, e.g. "fe80::457f:bbee:d579:1063%wlan0"
+ addr = addr[:addr.find("%")]
+ return netaddr.IPNetwork("{}/{}".format(addr, prefix))
except:
pass
From 8e39eac2079f4a7990bcf372a800979e988cfd13 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 19 Oct 2018 14:17:16 +0200
Subject: [PATCH 034/183] discovery: start name counter at 1
We want our second instance with the same name to show up as (2) not (1)
---
src/octoprint/plugins/discovery/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/octoprint/plugins/discovery/__init__.py b/src/octoprint/plugins/discovery/__init__.py
index 90e50cc15..d5fb2fb41 100644
--- a/src/octoprint/plugins/discovery/__init__.py
+++ b/src/octoprint/plugins/discovery/__init__.py
@@ -195,7 +195,7 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin,
key = (reg_type, port)
- counter = 0
+ counter = 1
while True:
try:
self._sd_refs[key] = pybonjour.DNSServiceRegister(**params)
From 757dfcf5c7da9b7b154dd538ab84443ca643a3e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 19 Oct 2018 16:19:51 +0200
Subject: [PATCH 035/183] unmap ipv6 mapped v4 addresses on lan check
---
src/octoprint/util/net.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/octoprint/util/net.py b/src/octoprint/util/net.py
index 494102887..0b7a00bd7 100644
--- a/src/octoprint/util/net.py
+++ b/src/octoprint/util/net.py
@@ -25,6 +25,10 @@ else:
HAS_V6 = False
def is_lan_address(address, additional_private=None):
+ if address.lower().startswith("::ffff:" and "." in address):
+ # ipv6 mapped ipv4 address, unmap
+ address = address[len("::ffff:"):]
+
ip = netaddr.IPAddress(address)
if ip.is_private() or ip.is_loopback():
return True
From 169275b052a27317bf25b1aef3d4f5c76b932935 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 19 Oct 2018 16:39:18 +0200
Subject: [PATCH 036/183] Fix wrong position of parentheses, add unit tests
---
src/octoprint/util/net.py | 2 +-
tests/util/test_net.py | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/octoprint/util/net.py b/src/octoprint/util/net.py
index 0b7a00bd7..2ca5cfea3 100644
--- a/src/octoprint/util/net.py
+++ b/src/octoprint/util/net.py
@@ -25,7 +25,7 @@ else:
HAS_V6 = False
def is_lan_address(address, additional_private=None):
- if address.lower().startswith("::ffff:" and "." in address):
+ if address.lower().startswith("::ffff:") and "." in address:
# ipv6 mapped ipv4 address, unmap
address = address[len("::ffff:"):]
diff --git a/tests/util/test_net.py b/tests/util/test_net.py
index e773ddac4..a1a33cec0 100644
--- a/tests/util/test_net.py
+++ b/tests/util/test_net.py
@@ -38,6 +38,8 @@ class UtilNetTest(unittest.TestCase):
("10.1.2.3", [], True),
("fc00::1", [], True),
("::1", [], True),
+ ("::ffff:192.168.1.1", [], True),
+ ("::ffff:8.8.8.8", [], False),
("11.1.2.3", [], False),
("11.1.2.3", ["11/8"], True),
("12.1.1.123", [], True),
From b77380a8ac7255f3331d9689c3776a4b4fab13fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 19 Oct 2018 16:50:58 +0200
Subject: [PATCH 037/183] Add logging for active/passive login
---
src/octoprint/server/api/__init__.py | 5 ++++-
src/octoprint/server/util/flask.py | 5 +++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/octoprint/server/api/__init__.py b/src/octoprint/server/api/__init__.py
index bf9b7efbe..ed4cc7cee 100644
--- a/src/octoprint/server/api/__init__.py
+++ b/src/octoprint/server/api/__init__.py
@@ -215,9 +215,12 @@ def login():
login_user(user, remember=remember)
identity_changed.send(current_app._get_current_object(), identity=Identity(user.get_id()))
+ remote_addr = get_remote_address(request)
+ logging.getLogger(__name__).info("Actively logging in user {} from {}".format(user.get_id(), remote_addr))
+
response = user.asDict()
response["_is_external_client"] = s().getBoolean(["server", "ipCheck", "enabled"]) \
- and not util_net.is_lan_address(get_remote_address(request),
+ and not util_net.is_lan_address(remote_addr,
additional_private=s().get(["server", "ipCheck", "trustedSubnets"]))
return jsonify(response)
diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py
index 567291bbd..3eab0c30f 100644
--- a/src/octoprint/server/util/flask.py
+++ b/src/octoprint/server/util/flask.py
@@ -526,6 +526,8 @@ def passive_login():
flask.session["usersession.id"] = user.session
flask.g.user = user
+ logging.getLogger(__name__).info("Passively logging in user {} from {}".format(user.get_id(), remoteAddr))
+
response = user.asDict()
response["_is_external_client"] = ipCheckEnabled and not is_lan_address(remoteAddr,
additional_private=ipCheckTrusted)
@@ -551,6 +553,9 @@ def passive_login():
flask_principal.identity_changed.send(flask.current_app._get_current_object(),
identity=flask_principal.Identity(user.get_id()))
+ logging.getLogger(__name__).info("Passively logging in user {} from {} via autologin".format(user.get_id(),
+ remoteAddr))
+
response = user.asDict()
response["_is_external_client"] = ipCheckEnabled and not is_lan_address(remoteAddr,
additional_private=ipCheckTrusted)
From 087a9ece2c2b8fd290d592bee87b8b4c849da576 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Fri, 19 Oct 2018 17:00:42 +0200
Subject: [PATCH 038/183] Make sure to show only one external address warning
notification at once
---
src/octoprint/static/js/app/viewmodels/loginstate.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/octoprint/static/js/app/viewmodels/loginstate.js b/src/octoprint/static/js/app/viewmodels/loginstate.js
index c67273c2a..d00e7f804 100644
--- a/src/octoprint/static/js/app/viewmodels/loginstate.js
+++ b/src/octoprint/static/js/app/viewmodels/loginstate.js
@@ -20,6 +20,8 @@ $(function() {
self.elementPasswordInput = undefined;
self.elementLoginButton = undefined;
+ self.externalAddressNotification = undefined;
+
self.userMenuText = ko.pureComputed(function() {
if (self.loggedIn()) {
return self.username();
@@ -80,10 +82,15 @@ $(function() {
"everyone with an internet connection.Please see " +
"this blog post for " +
"ways to safely access your OctoPrint instance from remote.
" +
- "If you know what you are doing or you are sure this message is" +
+ "
If you know what you are doing or you are sure this message is " +
"mistaken since you are in an isolated LAN, feel free to ignore it.
");
text = _.sprintf(text, {url: "https://octoprint.org/blog/2018/09/03/safe-remote-access/"});
- new PNotify({
+
+ if (self.externalAddressNotification !== undefined) {
+ self.externalAddressNotification.remove();
+ }
+
+ self.externalAddressNotification = new PNotify({
title: gettext("Possible external access detected"),
text: text,
hide: false,
From c4167a82c519f647493e9714993c68b23362dca1 Mon Sep 17 00:00:00 2001
From: Gaston Dombiak
Date: Sun, 21 Oct 2018 00:58:14 -0700
Subject: [PATCH 039/183] Fixed unsafe write_message call from another thread.
Issue #2850
---
.../sockjs/tornado/transports/rawwebsocket.py | 16 +++++++++++-----
.../sockjs/tornado/transports/websocket.py | 16 +++++++++++-----
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/src/octoprint/vendor/sockjs/tornado/transports/rawwebsocket.py b/src/octoprint/vendor/sockjs/tornado/transports/rawwebsocket.py
index d5dd6efc7..00e494b6d 100644
--- a/src/octoprint/vendor/sockjs/tornado/transports/rawwebsocket.py
+++ b/src/octoprint/vendor/sockjs/tornado/transports/rawwebsocket.py
@@ -10,6 +10,7 @@ import socket
from octoprint.vendor.sockjs.tornado import websocket, session
from octoprint.vendor.sockjs.tornado.transports import base
+from tornado.ioloop import IOLoop
LOG = logging.getLogger("tornado.general")
@@ -74,11 +75,16 @@ class RawWebSocketTransport(websocket.SockJSWebSocketHandler, base.BaseTransport
session.close()
def send_pack(self, message, binary=False):
- # Send message
- try:
- self.write_message(message, binary)
- except IOError:
- self.server.io_loop.add_callback(self.on_close)
+ if IOLoop.current(False) == self.server.io_loop:
+ # Running in Main Thread
+ # Send message
+ try:
+ self.write_message(message, binary)
+ except IOError:
+ self.server.io_loop.add_callback(self.on_close)
+ else:
+ # Not running in Main Thread so use proper thread to send message
+ self.server.io_loop.add_callback(lambda: self.send_pack(message, binary))
def session_closed(self):
try:
diff --git a/src/octoprint/vendor/sockjs/tornado/transports/websocket.py b/src/octoprint/vendor/sockjs/tornado/transports/websocket.py
index 8df3a2901..644b14543 100644
--- a/src/octoprint/vendor/sockjs/tornado/transports/websocket.py
+++ b/src/octoprint/vendor/sockjs/tornado/transports/websocket.py
@@ -11,6 +11,7 @@ import socket
from octoprint.vendor.sockjs.tornado import proto, websocket
from octoprint.vendor.sockjs.tornado.transports import base
from octoprint.vendor.sockjs.tornado.util import bytes_to_str
+from tornado.ioloop import IOLoop
LOG = logging.getLogger("tornado.general")
@@ -81,11 +82,16 @@ class WebSocketTransport(websocket.SockJSWebSocketHandler, base.BaseTransportMix
session.close()
def send_pack(self, message, binary=False):
- # Send message
- try:
- self.write_message(message, binary)
- except IOError:
- self.server.io_loop.add_callback(self.on_close)
+ if IOLoop.current(False) == self.server.io_loop:
+ # Running in Main Thread
+ # Send message
+ try:
+ self.write_message(message, binary)
+ except IOError:
+ self.server.io_loop.add_callback(self.on_close)
+ else:
+ # Not running in Main Thread so use proper thread to send message
+ self.server.io_loop.add_callback(lambda: self.send_pack(message, binary))
def session_closed(self):
# If session was closed by the application, terminate websocket
From e9e4adf09bdcfa7d5fa7a91cde5bfc844fe4a307 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Mon, 22 Oct 2018 13:01:42 +0200
Subject: [PATCH 040/183] tracking: flask.ext.babel => flask_babel
---
src/octoprint/plugins/tracking/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/octoprint/plugins/tracking/__init__.py b/src/octoprint/plugins/tracking/__init__.py
index 2dca12454..038008d05 100644
--- a/src/octoprint/plugins/tracking/__init__.py
+++ b/src/octoprint/plugins/tracking/__init__.py
@@ -6,7 +6,7 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
import octoprint.plugin
-from flask.ext.babel import gettext
+from flask_babel import gettext
import requests
import hashlib
From 6d2be1743a4f98b25e5b9cc10a44d3517525a339 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Mon, 22 Oct 2018 13:02:57 +0200
Subject: [PATCH 041/183] Update some dependencies
There are more updates, but they introduce backwards compatibility
issues that would hurt third party plugins, so we need to find
workarounds for these first - or trigger a grace period.
---
setup.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/setup.py b/setup.py
index ba2412f48..3582c90a8 100644
--- a/setup.py
+++ b/setup.py
@@ -14,11 +14,11 @@ import octoprint_setuptools
# Requirements for our application
INSTALL_REQUIRES = [
- "flask>=0.10.1,<0.11",
+ "flask>=1.0.2,<1.1",
"Jinja2>=2.8.1,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
# guarantee backwards compatibility for plugins and such with that
# version, hence we need to pin to a lower version for now. See #1697
- "werkzeug>=0.8.3,<0.9",
+ "werkzeug>=0.14.1,<0.15",
"tornado==4.5.3",
#"sockjs-tornado>=1.0.3,<1.1", # current version is incompatible to tornado 5, we use a
# vendored one
@@ -34,7 +34,7 @@ INSTALL_REQUIRES = [
"sarge==0.1.5post0",
"netifaces>=0.10.6,<0.11",
"pylru>=1.0.9,<1.1",
- "rsa>=3.2.3,<3.3",
+ "rsa>=4.0,<4.1",
"pkginfo>=1.4.2,<1.5",
"requests>=2.18.4,<3",
"semantic_version>=2.4.2,<2.5",
From 5e490ec7fd35008f570a7770e6ef9103ad8c4597 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Mon, 22 Oct 2018 16:19:42 +0200
Subject: [PATCH 042/183] Revert "Update some dependencies"
This reverts commit 6d2be17
---
setup.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/setup.py b/setup.py
index 75fc67962..0c48481af 100644
--- a/setup.py
+++ b/setup.py
@@ -17,11 +17,11 @@ PYTHON_REQUIRES = ">=2.7.3,<3" # TODO change to >=2.7.9,<3 in 1.3.11
# Requirements for our application
INSTALL_REQUIRES = [
- "flask>=1.0.2,<1.1",
+ "flask>=0.10.1,<0.11",
"Jinja2>=2.8.1,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
# guarantee backwards compatibility for plugins and such with that
# version, hence we need to pin to a lower version for now. See #1697
- "werkzeug>=0.14.1,<0.15",
+ "werkzeug>=0.8.3,<0.9",
"tornado==4.5.3",
#"sockjs-tornado>=1.0.3,<1.1", # current version is incompatible to tornado 5, we use a
# vendored one
@@ -37,7 +37,7 @@ INSTALL_REQUIRES = [
"sarge==0.1.5post0",
"netifaces>=0.10.6,<0.11",
"pylru>=1.0.9,<1.1",
- "rsa>=4.0,<4.1",
+ "rsa>=3.2.3,<3.3",
"pkginfo>=1.4.2,<1.5",
"requests>=2.18.4,<3",
"semantic_version>=2.4.2,<2.5",
From 1d15c2a176d8baa620ea4336f981b851874eb373 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?=
Date: Mon, 22 Oct 2018 16:42:47 +0200
Subject: [PATCH 043/183] backup: docs & small changes in wording
---
docs/bundledplugins/backup.rst | 70 ++++++++++++++++++
docs/bundledplugins/index.rst | 1 +
.../images/bundledplugins-backup-settings.png | Bin 0 -> 67683 bytes
src/octoprint/plugins/backup/__init__.py | 16 +++-
4 files changed, 85 insertions(+), 2 deletions(-)
create mode 100644 docs/bundledplugins/backup.rst
create mode 100644 docs/images/bundledplugins-backup-settings.png
diff --git a/docs/bundledplugins/backup.rst b/docs/bundledplugins/backup.rst
new file mode 100644
index 000000000..350d40508
--- /dev/null
+++ b/docs/bundledplugins/backup.rst
@@ -0,0 +1,70 @@
+.. _sec-bundledplugins-backup:
+
+Backup Plugin
+=============
+
+The OctoPrint Backup Plugin comes bundled with OctoPrint (starting with 1.3.10).
+
+It allows the creation and restoration of backups of OctoPrint's settings, data and installed plugins [#]_.
+
+This allows easy migration
+to newly setup instances as well as making regular backups to prevent data loss.
+
+.. _fig-bundledplugins-backup-settings:
+.. figure:: ../images/bundledplugins-backup-settings.png
+ :align: center
+ :alt: OctoPrint Backup Plugin
+
+ The plugin's settings panel with existing backups, the backup creation and restore sections.
+
+As long as plugins adhere to the standard of storing their data and settings in OctoPrint's plugin data folders, their
+data will be part of the backup. Note that the backups made by the Backup Plugin will *not* be part of any backups -
+you'll need to persist the resulting zip files yourself!
+
+.. _sec-bundledplugins-backup-cli:
+
+Command line usage
+------------------
+
+The Backup Plugin implements a command line interface that allows creation and restoration of backups.
+It adds two new commands, ``backup:backup`` and ``backup_restore``.
+
+.. code-block:: none
+
+ $ octoprint plugins backup:backup --help
+ Initializing settings & plugin subsystem...
+ Usage: octoprint plugins backup:backup [OPTIONS]
+
+ Creates a new backup.
+
+ Options:
+ --exclude TEXT Identifiers of data folders to exclude, e.g. 'uploads' to
+ exclude uploads or 'timelapse' to exclude timelapses.
+ --help Show this message and exit.
+
+ $ octoprint plugins backup:restore --help
+ Initializing settings & plugin subsystem...
+ Usage: octoprint plugins backup:restore [OPTIONS] PATH
+
+ Restores an existing backup from the backup zip provided as argument.
+
+ OctoPrint does not need to run for this to proceed.
+
+ Options:
+ --help Show this message and exit.
+
+.. note::
+
+ The ``backup:backup`` command can be useful in combination with a cronjob to create backups in regular intervals.
+
+.. _sec-bundledplugins-backup-sourcecode:
+
+Source code
+-----------
+
+The source of the Backup plugin is bundled with OctoPrint and can be found in
+its source repository under ``src/octoprint/plugins/backup``.
+
+.. [#] Note that only those plugins that are available on `OctoPrint's official plugin repository `_
+ can be automatically restored. If you have plugins installed that are not available on there you'll get their
+ names and - if available - homepage URL displayed after restore in order to be able to manually reinstall them.
diff --git a/docs/bundledplugins/index.rst b/docs/bundledplugins/index.rst
index 7dc337991..ec90f709c 100644
--- a/docs/bundledplugins/index.rst
+++ b/docs/bundledplugins/index.rst
@@ -9,6 +9,7 @@ Bundled Plugins
action_command_prompt.rst
announcements.rst
+ backup.rst
cura.rst
discovery.rst
logging.rst
diff --git a/docs/images/bundledplugins-backup-settings.png b/docs/images/bundledplugins-backup-settings.png
new file mode 100644
index 0000000000000000000000000000000000000000..1d21c69e8e0965a6b0b4304d3a06fb037d5b467b
GIT binary patch
literal 67683
zcmb@u2~?8X+c#`^%5%!2O{S$r{X1o*X`akktjz3a4rR^*6{j2#5phN{Pg$ALsHLf?
zsX3CR;0QJ-nFCIU0g6eAib#lng6Mlw|L1+4_j|u#t?zkR%Z19#-uvGBnts>yyY4%#
z&i21=+Pz6ZLE-nm&Yr%YprFVAe!_m;2>ho!=S2|kwhnp0{**#ZuhtCk$1i~=olYt!
z)M7TTT;2fu{aeIYZ=`~P$_M$+IuiWV-wFzAC4Zehc`-I%P9`P#x##huQq@I6nP55G
zm(C%Ku&tKfrHMWasy5@NskfjB^nl$DJC69;*=-mM2;y$EJ7E{L`;=>u((aS{U!5Gd
zq||>%-Dv&6EjRvo`QgC*vuFSK=a1`ial;AMTD!=Szq=i)>koU^4|A4d?_KOM@6dvF
zd)HUY`oFDMXjzjHEAO5vbUn0V)6E}mpXajJ?!cNA6fO;KZCEG&MI$93MVh?ETXXs^
z*KIoR*dQatGG>v1B>(=Im%Ntn?*V?i?YwxW(JXN4;gxaGMinXg&iZw{&J
zf%J6r3@u}`Pl+G5RXY?=JVKIJ_@qjZY}%eeP7=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