summaryrefslogtreecommitdiff
path: root/addons/http_routing
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2020-08-18 07:19:51 +0000
committerXavier Morel <xmo@odoo.com>2020-08-19 13:41:24 +0000
commit9e27956aa960dc9eea442418c83f5b3941b0c447 (patch)
tree71d8970e2e691a18e341674f928fdaa1916a54d4 /addons/http_routing
parent6b8d0432e2354ed50623386a2c1a052fdd809026 (diff)
[FIX] core: handle cors preflight with custom auth
Odoo provides basic handling of CORS preflight requests: if an endpoint is marked as `cors=<truthy value>` then it'll automatically reply allowing the request. *However* this is performed in `HttpRequest.dispatch` (likely in order to correctly handle the nodb case), which means it's executed after the auth handler has run... which means custom auth handlers will be called on preflight requests. This is a problem because they are missing relevant information (e.g. which endpoint they're invoked for), plus having to deal with preflight requests in every custom auth handler is annoying, and simply allowing preflights could cause issues if the decision diverges between the auth handler and the automatic handling. To fix this issue, extract the preflight *decision* into a separate method so we get the same decision-making process everywhere, and in case of CORS preflight set the auth to none to limit the eventual capacity for nuisance in the span between the bypassed auth and the automated preflight handling. Also change the signature of IrHttp._authenticate so it's clearer if a callsite was forgotten somehow (and this makes for less changes and duplication at the callsites). closes odoo/odoo#56029 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'addons/http_routing')
-rw-r--r--addons/http_routing/models/ir_http.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py
index 6da75e3ef61..206d63f429e 100644
--- a/addons/http_routing/models/ir_http.py
+++ b/addons/http_routing/models/ir_http.py
@@ -447,7 +447,7 @@ class IrHttp(models.AbstractModel):
# check authentication level
try:
if func:
- cls._authenticate(func.routing['auth'])
+ cls._authenticate(func)
elif request.uid is None and request.is_frontend:
cls._auth_method_public()
except Exception as e: