Deprecate appkey API in favor of Application Keys Plugin
Slated to be removed in 1.4.0. AFAIK nobody used it anyhow.
This commit is contained in:
1 parent
45b59494ca
commit
002802bb20
5 files changed
+18
-27
No files matched your search
@@ -11,6 +11,10 @@ Apps
|
||||
Session Keys
|
||||
============
|
||||
|
||||
.. deprecated:: 1.3.11
|
||||
|
||||
This functionality will be removed in 1.4.0. Use the :ref:`Application Keys Plugin workflow <sec-bundledplugins-appkeys-workflow>` instead.
|
||||
|
||||
OctoPrint offers a special API key type for apps to use, the so called App Session Key. These keys have a time based
|
||||
validity and are generated by OctoPrint for requesting apps.
|
||||
|
||||
|
||||
@@ -208,6 +208,10 @@ octoprint.accesscontrol.appkey
|
||||
|
||||
.. py:function:: acl_appkey_hook(*args, **kwargs)
|
||||
|
||||
.. deprecated:: 1.3.11
|
||||
|
||||
This functionality will be removed in 1.4.0. Use the :ref:`Application Keys Plugin workflow <sec-bundledplugins-appkeys-workflow>` instead.
|
||||
|
||||
By handling this hook plugins may register additional :ref:`App session key providers <sec-api-apps-sessionkey>`
|
||||
within the system.
|
||||
|
||||
|
||||
@@ -33,16 +33,6 @@ from octoprint.util import deprecated
|
||||
_instance = None
|
||||
|
||||
def _validate_plugin(phase, plugin_info):
|
||||
if phase == "after_load":
|
||||
if plugin_info.implementation is not None and isinstance(plugin_info.implementation, AppPlugin):
|
||||
# transform app plugin into hook
|
||||
import warnings
|
||||
warnings.warn("{name} uses deprecated plugin mixin AppPlugin, use octoprint.accesscontrol.appkey hook instead".format(name=plugin_info.key), DeprecationWarning)
|
||||
|
||||
hooks = plugin_info.hooks
|
||||
if not "octoprint.accesscontrol.appkey" in hooks:
|
||||
hooks["octoprint.accesscontrol.appkey"] = plugin_info.implementation.get_additional_apps
|
||||
setattr(plugin_info.instance, PluginInfo.attr_hooks, hooks)
|
||||
return True
|
||||
|
||||
def plugin_manager(init=False, plugin_folders=None, plugin_bases=None, plugin_entry_points=None, plugin_disabled_list=None,
|
||||
|
||||
@@ -2059,20 +2059,3 @@ class ProgressPlugin(OctoPrintPlugin):
|
||||
:param int progress: Current progress as a value between 0 and 100
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class AppPlugin(OctoPrintPlugin):
|
||||
"""
|
||||
Using the :class:`AppPlugin mixin` plugins may register additional :ref:`App session key providers <sec-api-apps-sessionkey>`
|
||||
within the system.
|
||||
|
||||
.. deprecated:: 1.2.0
|
||||
|
||||
Refer to the :ref:`octoprint.accesscontrol.appkey hook <sec-plugins-hook-accesscontrol-appkey>` instead.
|
||||
|
||||
"""
|
||||
|
||||
# noinspection PyMethodMayBeStatic
|
||||
def get_additional_apps(self):
|
||||
return []
|
||||
|
||||
@@ -7,13 +7,17 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
|
||||
import rsa
|
||||
from flask import Blueprint, request, make_response, jsonify
|
||||
import logging
|
||||
|
||||
import octoprint.server
|
||||
import octoprint.plugin
|
||||
|
||||
from octoprint.server.util import noCachingResponseHandler, corsResponseHandler
|
||||
from octoprint.server.util.flask import get_remote_address
|
||||
from octoprint.settings import settings as s
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
apps = Blueprint("apps", __name__)
|
||||
|
||||
apps.after_request(noCachingResponseHandler)
|
||||
@@ -21,11 +25,16 @@ apps.after_request(corsResponseHandler)
|
||||
|
||||
@apps.route("/auth", methods=["GET"])
|
||||
def getSessionKey():
|
||||
logger.warn("Client {} accessed the apps API which has been deprecated since 1.3.11 and will be removed in "
|
||||
"1.4.0. Clients should use the Application Keys Plugin workflow instead".format(get_remote_address(request)))
|
||||
unverified_key, valid_until = octoprint.server.appSessionManager.create()
|
||||
return jsonify(unverifiedKey=unverified_key, validUntil=valid_until)
|
||||
|
||||
@apps.route("/auth", methods=["POST"])
|
||||
def verifySessionKey():
|
||||
logger.warn("Client {} accessed the apps API which has been deprecated since 1.3.11 and will be removed in "
|
||||
"1.4.0. Clients should use the Application Keys Plugin workflow instead".format(get_remote_address(request)))
|
||||
|
||||
if not "application/json" in request.headers["Content-Type"]:
|
||||
return None, None, make_response("Expected content-type JSON", 400)
|
||||
|
||||
@@ -95,6 +104,7 @@ def _get_registered_apps():
|
||||
for name, hook in hooks.items():
|
||||
try:
|
||||
additional_apps = hook()
|
||||
logger.warn("Plugin {} is still implementing the appkey hook that is deprecated since 1.3.11 and will be removed in 1.4.0. Switch it over to the Application Keys Plugin workflow.".format(name))
|
||||
except:
|
||||
import logging
|
||||
logging.getLogger(__name__).exception("Error while retrieving additional appkeys from plugin {name}".format(**locals()))
|
||||
|
||||
Reference in new issue
Block a user