From f18510f67d2d1fa19b0147229e008c49bdf2ece9 Mon Sep 17 00:00:00 2001 From: default Date: Sat, 1 Jun 2024 19:31:45 +0200 Subject: [PATCH] [FIX] allow ``/oauth/userinfo`` GET request with json content-type This is required by some services (like ``outline``) --- galicea_openid_connect/controllers/main.py | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/galicea_openid_connect/controllers/main.py b/galicea_openid_connect/controllers/main.py index 423cac6..4a152bc 100644 --- a/galicea_openid_connect/controllers/main.py +++ b/galicea_openid_connect/controllers/main.py @@ -410,3 +410,30 @@ class Main(http.Controller): response=None, status=302, ) + + +from odoo.http import Root, HttpRequest + + +def patch_get_request(f): + """Allow ``/oauth/userinfo`` GET request to be accepted for outline + + Outline (and probably other services) can implement OIDC by adding a + ``content-type`` set to "application/json". This makes odoo 14 use + JsonRequest object that will refuse the request. + + This is monkey-patching, and is not meant to be a final solution, but + only a temporary one. + + """ + + def patched(self, httprequest): + if httprequest.path == "/oauth/userinfo" and \ + httprequest.method == "GET": + return HttpRequest(httprequest) + return f(self, httprequest) + + return patched + + +Root.get_request = patch_get_request(Root.get_request)