itpp-labs/sync-addons

openapi: web unaccessible when authentication enabled on nginx

mkrnac-implemento opened this issue · 1 comments

When authentication is enabled on nginx, odoo web (backend) is unaccessible at all.
It is enabled on nginx like this:

    auth_basic "Protected area";
	auth_basic_user_file /etc/nginx/.htpasswd;

and here is the stack:

Nov 22 03:46:09 odoo-test odoo[127092]: 2021-11-22 03:46:09,257 127092 INFO test-1 werkzeug: ***** - - [22/Nov/2021 03:46:09] "POST /web/webclient/version_info HTTP/1.1" 500 - 1 0.001 0.005
Nov 22 03:46:09 odoo-test odoo[127094]: 2021-11-22 03:46:09,260 127094 INFO test-1 odoo.http: <function BusController.poll at 0x7f5732afc5e0>, /longpolling/poll: Function declared as capable of handling request of type 'json' but called with a request of type 'apijson'
Nov 22 03:46:09 odoo-test odoo[127094]: 2021-11-22 03:46:09,260 127094 ERROR test-1 odoo.addons.openapi.controllers.apijsonrequest: Exception during JSON request handling.
Nov 22 03:46:09 odoo-test odoo[127094]: Traceback (most recent call last):
Nov 22 03:46:09 odoo-test odoo[127094]:   File "/opt/odoo/addons_custom/openapi/controllers/apijsonrequest.py", line 163, in dispatch
Nov 22 03:46:09 odoo-test odoo[127094]:     result = self._call_function(**self.params)
Nov 22 03:46:09 odoo-test odoo[127094]:   File "/opt/odoo/odoo/http.py", line 327, in _call_function
Nov 22 03:46:09 odoo-test odoo[127094]:     raise werkzeug.exceptions.BadRequest(msg % params)
Nov 22 03:46:09 odoo-test odoo[127094]: Exception
Nov 22 03:46:09 odoo-test odoo[127094]: The above exception was the direct cause of the following exception:
Nov 22 03:46:09 odoo-test odoo[127094]: Traceback (most recent call last):
Nov 22 03:46:09 odoo-test odoo[127094]:   File "/opt/odoo/addons_custom/openapi/controllers/apijsonrequest.py", line 111, in _handle_exception
Nov 22 03:46:09 odoo-test odoo[127094]:     return super(ApiJsonRequest, self)._handle_exception(exception)
Nov 22 03:46:09 odoo-test odoo[127094]:   File "/opt/odoo/odoo/http.py", line 316, in _handle_exception
Nov 22 03:46:09 odoo-test odoo[127094]:     raise exception.with_traceback(None) from new_cause
Nov 22 03:46:09 odoo-test odoo[127094]: werkzeug.exceptions.BadRequest: 400 Bad Request: <function BusController.poll at 0x7f5732afc5e0>, /longpolling/poll: Function declared as capable of handling request of type 'json' but called with a request of type 'apijson'
Nov 22 03:46:09 odoo-test odoo[127094]: 2021-11-22 03:46:09,260 127094 ERROR test-1 odoo.addons.openapi.controllers.apijsonrequest: Exception during JSON request handling.
Nov 22 03:46:09 odoo-test odoo[127094]: Traceback (most recent call last):
Nov 22 03:46:09 odoo-test odoo[127094]:   File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
Nov 22 03:46:09 odoo-test odoo[127094]:     result = request.dispatch()
Nov 22 03:46:09 odoo-test odoo[127094]:   File "/opt/odoo/addons_custom/openapi/controllers/apijsonrequest.py", line 185, in dispatch
Nov 22 03:46:09 odoo-test odoo[127094]:     return self._handle_exception(e)
Nov 22 03:46:09 odoo-test odoo[127094]:   File "/opt/odoo/addons_custom/openapi/controllers/apijsonrequest.py", line 127, in _handle_exception
Nov 22 03:46:09 odoo-test odoo[127094]:     "openapi_message": exception.args[0],
Nov 22 03:46:09 odoo-test odoo[127094]: Exception
Nov 22 03:46:09 odoo-test odoo[127094]: The above exception was the direct cause of the following exception:
Nov 22 03:46:09 odoo-test odoo[127094]: Traceback (most recent call last):
Nov 22 03:46:09 odoo-test odoo[127094]:   File "/opt/odoo/addons_custom/openapi/controllers/apijsonrequest.py", line 111, in _handle_exception
Nov 22 03:46:09 odoo-test odoo[127094]:     return super(ApiJsonRequest, self)._handle_exception(exception)
Nov 22 03:46:09 odoo-test odoo[127094]:   File "/opt/odoo/odoo/http.py", line 316, in _handle_exception
Nov 22 03:46:09 odoo-test odoo[127094]:     raise exception.with_traceback(None) from new_cause
Nov 22 03:46:09 odoo-test odoo[127094]: IndexError: tuple index out of range

This is our test instance, which is not supposed to be accessed by public, that is the reason why we need authentication enabled on nginx. REST API should be accessed directly bypassing nginx web server (through ssh tunnel).

Hello!
This seems doesn't related to openapi module directly. For example, the logs even has error about /longpolling/poll

Nov 22 03:46:09 odoo-test odoo[127094]: werkzeug.exceptions.BadRequest: 400 Bad Request: <function BusController.poll at 0x7f5732afc5e0>, /longpolling/poll: Function declared as capable of handling request of type 'json' but called with a request of type 'apijson'