From 0843c0fbc7db58cf0266ffdac2711ce9da43b804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 24 Apr 2019 16:26:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Reflect=20API=20key=20changes=20?= =?UTF-8?q?in=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3121 --- docs/api/general.rst | 31 +++++++++++++++++++++---------- docs/features/accesscontrol.rst | 4 ++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/docs/api/general.rst b/docs/api/general.rst index edc54ed78..3c404724c 100644 --- a/docs/api/general.rst +++ b/docs/api/general.rst @@ -11,9 +11,9 @@ General information Authorization ============= -OctoPrint's API expects an API key to be supplied with each request. This API key can be either the globally -configured one, a user specific one if "Access Control" is enabled or an app and user specific one as generated -by the authorization workflow implemented by the bundled :ref:`Application Keys Plugin ` (since 1.3.10). +If :ref:`Access Control ` is enabled OctoPrint's API expects an API key to be supplied with each request. This API +key can be either the globally configured one, a user specific one or an app and user specific one as generated by the +authorization workflow implemented by the bundled :ref:`Application Keys Plugin ` (since 1.3.10). Clients are advised to implement the :ref:`Application Keys Plugin workflow ` first and fallback on directing the user to manually supply the the user specific API key. The global key should rarely be used. @@ -26,8 +26,6 @@ The API key must be supplied in the custom HTTP header ``X-Api-Key``, e.g. Host: example.com X-Api-Key: abcdef... -If it is missing or included but invalid, OctoPrint will directly return a response with status :http:statuscode:`403`. - For testing purposes it is also possible to supply the API key via a query parameter ``apikey``, e.g. .. sourcecode:: http @@ -37,6 +35,24 @@ For testing purposes it is also possible to supply the API key via a query param Please be advised that clients should use the header field variant if at all possible. +If the key is missing or invalid, OctoPrint will treat the request as it would any unauthenticated anonymous request to the endpoint. +Consequently, if the bundled :ref:`ForceLogin plugin ` is active (which is the default), that means +that any requests without or with an invalid API key targeting other API endpoints than :ref:`Login ` +will be denied with a :http:statuscode:`403`. + +.. warning:: + + If :ref:`Access Control ` is disabled, OctoPrint will treat any unauthenticated anonymous requests and thus also requests + with an invalid or outright missing API key as requests with full admin rights! + +.. note:: + + The API key requirements changed in 1.3.11. Up to that version, even if Access Control was disabled, all requests needed to + be supplied with an API Key. To make the webinterface work under these circumstances, an unauthenticated anonymous API key was injected into the + HTML page and also available on the :ref:`Push API `. The presence and ready availability of this unauthenticated + anonymous "UI API key" caused confusion and false alarm among users and didn't contribute to the security of the platform in a + meaningful way, so it was finally abandoned in 1.3.11. + .. _fig-api-general-globalapikey: .. figure:: ../images/settings-global-api-key.png :align: center @@ -58,11 +74,6 @@ Please be advised that clients should use the header field variant if at all pos The API key options in the "Change password" dialog. Users can generate and revoke their custom API key here. -.. note:: - OctoPrint's web interface uses a custom API key that is freshly generated on every server start. This key is not - intended to be used by any other client and would not be very useful in any case, since it basically represents - a completely anonymous client. - .. _sec-api-general-contenttype: Content Type diff --git a/docs/features/accesscontrol.rst b/docs/features/accesscontrol.rst index cb6a1e248..06bcc253e 100644 --- a/docs/features/accesscontrol.rst +++ b/docs/features/accesscontrol.rst @@ -21,12 +21,12 @@ Commands, which are admin-only. If Access Control is disabled, everything is directly accessible. **That also includes all administrative functionality as well as full control over the -printer!** +printer**, and without the need for an :ref:`API key `! Upon first start a configuration wizard is provided which allows configuration of the first administrator account or alternatively disabling Access Control (which is **NOT** recommended for systems that are directly accessible via the -Internet!). +internet or other untrusted networks!). .. hint::