From 85f6fa0182fede2006f56c7d2f3e678858ef907e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 22 Jun 2021 17:40:24 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Clarify=20cookies=20vs=20CORS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4174 --- docs/api/general.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/api/general.rst b/docs/api/general.rst index 0dacead1d..9b4db477b 100644 --- a/docs/api/general.rst +++ b/docs/api/general.rst @@ -134,7 +134,8 @@ check the corresponding checkbox in the API settings dialog. Support for CORS can be enabled in the "API" settings -.. note:: +.. warning:: + This means any browser page can send requests to the OctoPrint API. Authorization is still required however. If CORS is not enabled you will get errors like the following:: @@ -142,6 +143,15 @@ If CORS is not enabled you will get errors like the following:: XMLHttpRequest cannot load http://localhost:8081/api/files. No 'Access-Control-Allow-Origin' header is present on the requested resource. + +.. note:: + + For security reasons, OctoPrint will not set the ``Access-Control-Allow-Credentials`` + header, even if CORS support is enabled. That means that cookies will not be sent by + the browser to OctoPrint, effectively making it impossible to authenticate through + the login mechanism (or reusing an existing login session). When accessing OctoPrint + via CORS, you'll therefore always need to use an API key. + .. _sec-api-general-login: Login @@ -165,6 +175,12 @@ Login mismatch or an unknown user. That was incompatible with basic authentication since it was a wrong use of the :http:statuscode:`401` code and got therefore changed as part of a bug fix. + .. note:: + + You cannot use this endpoint to login from a third party page via CORS, see above. You can however use it + to retrieve user information via passive login with an API key (e.g. if you need the ``session`` to authenticate + on the web socket. + :json passive: If present, performs a passive login only, returning information about the current user that's active either through an existing session or the used API key :json user: (active login only) Username