From 3396c709d1f921109ece2b54ef13f8fd2867fdf9 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Tue, 9 Jul 2024 12:05:57 +0200 Subject: [PATCH 1/3] [FIX] fastapi: Unflag save_session in routing info --- fastapi/models/fastapi_endpoint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fastapi/models/fastapi_endpoint.py b/fastapi/models/fastapi_endpoint.py index a7608e27b..c324ef0e8 100644 --- a/fastapi/models/fastapi_endpoint.py +++ b/fastapi/models/fastapi_endpoint.py @@ -178,6 +178,7 @@ def _get_routing_info(self): f"{self.root_path}/", f"{self.root_path}/", ], + "save_session": False, # csrf ????? } From 4feb4fb388b4d570fadd4b3db805a788cd9459ff Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Tue, 1 Oct 2024 11:19:06 +0200 Subject: [PATCH 2/3] [IMP] fastapi: Makes the save_session configurable --- fastapi/models/fastapi_endpoint.py | 12 +++++++++++- fastapi/readme/newsfragments/442.feature | 1 + fastapi/views/fastapi_endpoint.xml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 fastapi/readme/newsfragments/442.feature diff --git a/fastapi/models/fastapi_endpoint.py b/fastapi/models/fastapi_endpoint.py index c324ef0e8..1312f07d1 100644 --- a/fastapi/models/fastapi_endpoint.py +++ b/fastapi/models/fastapi_endpoint.py @@ -55,6 +55,16 @@ class FastapiEndpoint(models.Model): readonly=False, domain="[('user_ids', 'in', user_id)]", ) + save_http_session = fields.Boolean( + string="Save HTTP Session", + help="Whether session should be saved into the session store. This is " + "required if for example you use the Odoo's authentication mechanism. " + "Oherwise chance are high that you don't need it and could turn off " + "this behaviour. Additionaly turning off this option will prevent useless " + "IO operation when storing and reading the session on the disk and prevent " + "unexpecteed disk space consumption.", + default=True, + ) @api.depends("root_path") def _compute_root_path(self): @@ -178,7 +188,7 @@ def _get_routing_info(self): f"{self.root_path}/", f"{self.root_path}/", ], - "save_session": False, + "save_session": self.save_http_session, # csrf ????? } diff --git a/fastapi/readme/newsfragments/442.feature b/fastapi/readme/newsfragments/442.feature new file mode 100644 index 000000000..f45f73ebf --- /dev/null +++ b/fastapi/readme/newsfragments/442.feature @@ -0,0 +1 @@ +* A new parameter is now available on the endpoint model to let you disable the creation and the store of session files used by Odoo for calls to your application endpoint. This is usefull to prevent disk space consumption and IO operations if your application doesn't need to use this sessions files which are mainly used by Odoo by to store the session info of logged in users. diff --git a/fastapi/views/fastapi_endpoint.xml b/fastapi/views/fastapi_endpoint.xml index e4a6c28c8..45e0a27de 100644 --- a/fastapi/views/fastapi_endpoint.xml +++ b/fastapi/views/fastapi_endpoint.xml @@ -46,7 +46,7 @@ - + From 1aff5c540e654524b433558701b8d499c3c2a474 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Tue, 1 Oct 2024 11:38:51 +0200 Subject: [PATCH 3/3] [LINT] fastapi --- fastapi/views/fastapi_endpoint.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastapi/views/fastapi_endpoint.xml b/fastapi/views/fastapi_endpoint.xml index 45e0a27de..6a6ede3fb 100644 --- a/fastapi/views/fastapi_endpoint.xml +++ b/fastapi/views/fastapi_endpoint.xml @@ -46,7 +46,8 @@ - + +