-
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathrequest_adapter.py
More file actions
30 lines (22 loc) · 1.09 KB
/
request_adapter.py
File metadata and controls
30 lines (22 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright 2026 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.addons.component.core import Component
class ClientCertRestRequestsAdapter(Component):
_inherit = "base.requests"
def _request(self, method, url=None, url_params=None, **kwargs):
if self.collection.auth_type == "client_certificate":
# ``requests`` ``cert`` parameter accepts:
# * A string: path to a file containing both certificate and private key
# * A tuple: ('/path/client.cert', '/path/client.key')
cert_path = self._get_cert_path()
key_path = self._get_key_path()
if "cert" not in kwargs and cert_path:
if key_path:
kwargs["cert"] = (cert_path, key_path)
else:
kwargs["cert"] = cert_path
return super()._request(method, url=url, url_params=url_params, **kwargs)
def _get_cert_path(self):
return self.collection.client_certificate_path
def _get_key_path(self):
return self.collection.client_private_key_path