Skip to content

Commit 1199ee9

Browse files
[IMP]auth_oidc: verify self-signed certificates
If the connection between odoo and an oauth provider uses self-signed certificates, a ssl error is thrown because the self-signed certificated cannot be verified.
1 parent 05bf187 commit 1199ee9

File tree

6 files changed

+58
-38
lines changed

6 files changed

+58
-38
lines changed

auth_oidc/README.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
=============================
62
Authentication OpenID Connect
73
=============================
@@ -17,7 +13,7 @@ Authentication OpenID Connect
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
@@ -38,6 +34,9 @@ using the authorization code flow or implicit flow.
3834
Note the implicit flow is not recommended because it exposes access
3935
tokens to the browser and in http logs.
4036

37+
Note disabling certificate checks is a security risk and not
38+
recommended. Use it with caution.
39+
4140
**Table of contents**
4241

4342
.. contents::

auth_oidc/models/auth_oauth_provider.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,22 @@ class AuthOauthProvider(models.Model):
4747
)
4848
jwks_uri = fields.Char(string="JWKS URL", help="Required for OpenID Connect.")
4949
end_session_endpoint = fields.Char(string="End Session URL")
50+
ca_bundle = fields.Char(
51+
string="CA bundle", help="Path to CA bundles to use for verification."
52+
)
53+
disable_certificate_check = fields.Boolean(
54+
string="Disable certificate check",
55+
help="Disable certificate check. This is a security risk. Use with caution.",
56+
)
5057

5158
@tools.ormcache("self.jwks_uri", "kid")
5259
def _get_keys(self, kid):
53-
r = requests.get(self.jwks_uri, timeout=10)
60+
verify = True
61+
if self.disable_certificate_check:
62+
verify = False
63+
elif self.ca_bundle:
64+
verify = self.ca_bundle
65+
r = requests.get(self.jwks_uri, timeout=10, verify=verify)
5466
r.raise_for_status()
5567
response = r.json()
5668
# the keys returned here should follow

auth_oidc/models/res_users.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def _auth_oauth_get_tokens_auth_code_flow(self, oauth_provider, params):
2727
auth = None
2828
if oauth_provider.client_secret:
2929
auth = (oauth_provider.client_id, oauth_provider.client_secret)
30+
verify = True
31+
if oauth_provider.disable_certificate_check:
32+
verify = False
33+
elif oauth_provider.ca_bundle:
34+
verify = oauth_provider.ca_bundle
3035
response = requests.post(
3136
oauth_provider.token_endpoint,
3237
data=dict(
@@ -38,6 +43,7 @@ def _auth_oauth_get_tokens_auth_code_flow(self, oauth_provider, params):
3843
),
3944
auth=auth,
4045
timeout=10,
46+
verifiy=verify,
4147
)
4248
response.raise_for_status()
4349
response_json = response.json()

auth_oidc/readme/DESCRIPTION.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ using the authorization code flow or implicit flow.
33

44
Note the implicit flow is not recommended because it exposes access
55
tokens to the browser and in http logs.
6+
7+
Note disabling certificate checks is a security risk and not recommended.
8+
Use it with caution.

auth_oidc/static/description/index.html

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Authentication OpenID Connect</title>
77
<style type="text/css">
88

99
/*
@@ -360,25 +360,22 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="authentication-openid-connect">
364+
<h1 class="title">Authentication OpenID Connect</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="authentication-openid-connect">
370-
<h1>Authentication OpenID Connect</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:d5e5a3781c5ed38c37634f69bdcfdce055fa97a302c49acd1ea9e25b4a610454
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-auth/tree/18.0/auth_oidc"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-18-0/server-auth-18-0-auth_oidc"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-auth&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-auth/tree/18.0/auth_oidc"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-18-0/server-auth-18-0-auth_oidc"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-auth&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This module allows users to login through an OpenID Connect provider
379374
using the authorization code flow or implicit flow.</p>
380375
<p>Note the implicit flow is not recommended because it exposes access
381376
tokens to the browser and in http logs.</p>
377+
<p>Note disabling certificate checks is a security risk and not
378+
recommended. Use it with caution.</p>
382379
<p><strong>Table of contents</strong></p>
383380
<div class="contents local topic" id="contents">
384381
<ul class="simple">
@@ -413,15 +410,15 @@ <h1>Authentication OpenID Connect</h1>
413410
</ul>
414411
</div>
415412
<div class="section" id="installation">
416-
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
413+
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
417414
<p>This module depends on the
418415
<a class="reference external" href="https://pypi.org/project/python-jose/">python-jose</a> library, not to
419416
be confused with <tt class="docutils literal">jose</tt> which is also available on PyPI.</p>
420417
</div>
421418
<div class="section" id="configuration">
422-
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
419+
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
423420
<div class="section" id="setup-for-microsoft-azure">
424-
<h3><a class="toc-backref" href="#toc-entry-3">Setup for Microsoft Azure</a></h3>
421+
<h2><a class="toc-backref" href="#toc-entry-3">Setup for Microsoft Azure</a></h2>
425422
<p>Example configuration with OpenID Connect authorization code flow.</p>
426423
<ol class="arabic simple">
427424
<li>configure a new web application in Azure with OpenID and code flow
@@ -457,7 +454,7 @@ <h3><a class="toc-backref" href="#toc-entry-3">Setup for Microsoft Azure</a></h3
457454
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/server-auth/18.0/auth_oidc/static/description/odoo-azure_ad_multitenant.png" /></p>
458455
</div>
459456
<div class="section" id="setup-for-keycloak">
460-
<h3><a class="toc-backref" href="#toc-entry-4">Setup for Keycloak</a></h3>
457+
<h2><a class="toc-backref" href="#toc-entry-4">Setup for Keycloak</a></h2>
461458
<p>Example configuration with OpenID Connect authorization code flow.</p>
462459
<p>In Keycloak:</p>
463460
<ol class="arabic simple">
@@ -490,11 +487,11 @@ <h3><a class="toc-backref" href="#toc-entry-4">Setup for Keycloak</a></h3>
490487
</div>
491488
</div>
492489
<div class="section" id="usage">
493-
<h2><a class="toc-backref" href="#toc-entry-5">Usage</a></h2>
490+
<h1><a class="toc-backref" href="#toc-entry-5">Usage</a></h1>
494491
<p>On the login page, click on the authentication provider you configured.</p>
495492
</div>
496493
<div class="section" id="known-issues-roadmap">
497-
<h2><a class="toc-backref" href="#toc-entry-6">Known issues / Roadmap</a></h2>
494+
<h1><a class="toc-backref" href="#toc-entry-6">Known issues / Roadmap</a></h1>
498495
<ul class="simple">
499496
<li>When going to the login screen, check for a existing token and do a
500497
direct login without the clicking on the SSO link</li>
@@ -503,88 +500,88 @@ <h2><a class="toc-backref" href="#toc-entry-6">Known issues / Roadmap</a></h2>
503500
</ul>
504501
</div>
505502
<div class="section" id="changelog">
506-
<h2><a class="toc-backref" href="#toc-entry-7">Changelog</a></h2>
503+
<h1><a class="toc-backref" href="#toc-entry-7">Changelog</a></h1>
507504
<div class="section" id="section-1">
508-
<h3><a class="toc-backref" href="#toc-entry-8">18.0.1.0.0 2024-10-09</a></h3>
505+
<h2><a class="toc-backref" href="#toc-entry-8">18.0.1.0.0 2024-10-09</a></h2>
509506
<ul class="simple">
510507
<li>Odoo 18 migration</li>
511508
</ul>
512509
</div>
513510
<div class="section" id="section-2">
514-
<h3><a class="toc-backref" href="#toc-entry-9">17.0.1.0.0 2024-03-20</a></h3>
511+
<h2><a class="toc-backref" href="#toc-entry-9">17.0.1.0.0 2024-03-20</a></h2>
515512
<ul class="simple">
516513
<li>Odoo 17 migration</li>
517514
</ul>
518515
</div>
519516
<div class="section" id="section-3">
520-
<h3><a class="toc-backref" href="#toc-entry-10">16.0.1.1.0 2024-02-28</a></h3>
517+
<h2><a class="toc-backref" href="#toc-entry-10">16.0.1.1.0 2024-02-28</a></h2>
521518
<ul class="simple">
522519
<li>Forward port OpenID Connect fixes from 15.0 to 16.0</li>
523520
</ul>
524521
</div>
525522
<div class="section" id="section-4">
526-
<h3><a class="toc-backref" href="#toc-entry-11">16.0.1.0.2 2023-11-16</a></h3>
523+
<h2><a class="toc-backref" href="#toc-entry-11">16.0.1.0.2 2023-11-16</a></h2>
527524
<ul class="simple">
528525
<li>Readme link updates</li>
529526
</ul>
530527
</div>
531528
<div class="section" id="section-5">
532-
<h3><a class="toc-backref" href="#toc-entry-12">16.0.1.0.1 2023-10-09</a></h3>
529+
<h2><a class="toc-backref" href="#toc-entry-12">16.0.1.0.1 2023-10-09</a></h2>
533530
<ul class="simple">
534531
<li>Add AzureAD code flow provider</li>
535532
</ul>
536533
</div>
537534
<div class="section" id="section-6">
538-
<h3><a class="toc-backref" href="#toc-entry-13">16.0.1.0.0 2023-01-27</a></h3>
535+
<h2><a class="toc-backref" href="#toc-entry-13">16.0.1.0.0 2023-01-27</a></h2>
539536
<ul class="simple">
540537
<li>Odoo 16 migration</li>
541538
</ul>
542539
</div>
543540
<div class="section" id="section-7">
544-
<h3><a class="toc-backref" href="#toc-entry-14">15.0.1.0.0 2023-01-06</a></h3>
541+
<h2><a class="toc-backref" href="#toc-entry-14">15.0.1.0.0 2023-01-06</a></h2>
545542
<ul class="simple">
546543
<li>Odoo 15 migration</li>
547544
</ul>
548545
</div>
549546
<div class="section" id="section-8">
550-
<h3><a class="toc-backref" href="#toc-entry-15">14.0.1.0.0 2021-12-10</a></h3>
547+
<h2><a class="toc-backref" href="#toc-entry-15">14.0.1.0.0 2021-12-10</a></h2>
551548
<ul class="simple">
552549
<li>Odoo 14 migration</li>
553550
</ul>
554551
</div>
555552
<div class="section" id="section-9">
556-
<h3><a class="toc-backref" href="#toc-entry-16">13.0.1.0.0 2020-04-10</a></h3>
553+
<h2><a class="toc-backref" href="#toc-entry-16">13.0.1.0.0 2020-04-10</a></h2>
557554
<ul class="simple">
558555
<li>Odoo 13 migration, add authorization code flow.</li>
559556
</ul>
560557
</div>
561558
<div class="section" id="section-10">
562-
<h3><a class="toc-backref" href="#toc-entry-17">10.0.1.0.0 2018-10-05</a></h3>
559+
<h2><a class="toc-backref" href="#toc-entry-17">10.0.1.0.0 2018-10-05</a></h2>
563560
<ul class="simple">
564561
<li>Initial implementation</li>
565562
</ul>
566563
</div>
567564
</div>
568565
<div class="section" id="bug-tracker">
569-
<h2><a class="toc-backref" href="#toc-entry-18">Bug Tracker</a></h2>
566+
<h1><a class="toc-backref" href="#toc-entry-18">Bug Tracker</a></h1>
570567
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-auth/issues">GitHub Issues</a>.
571568
In case of trouble, please check there if your issue has already been reported.
572569
If you spotted it first, help us to smash it by providing a detailed and welcomed
573570
<a class="reference external" href="https://github.com/OCA/server-auth/issues/new?body=module:%20auth_oidc%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
574571
<p>Do not contact contributors directly about support or help with technical issues.</p>
575572
</div>
576573
<div class="section" id="credits">
577-
<h2><a class="toc-backref" href="#toc-entry-19">Credits</a></h2>
574+
<h1><a class="toc-backref" href="#toc-entry-19">Credits</a></h1>
578575
<div class="section" id="authors">
579-
<h3><a class="toc-backref" href="#toc-entry-20">Authors</a></h3>
576+
<h2><a class="toc-backref" href="#toc-entry-20">Authors</a></h2>
580577
<ul class="simple">
581578
<li>ICTSTUDIO</li>
582579
<li>André Schenkels</li>
583580
<li>ACSONE SA/NV</li>
584581
</ul>
585582
</div>
586583
<div class="section" id="contributors">
587-
<h3><a class="toc-backref" href="#toc-entry-21">Contributors</a></h3>
584+
<h2><a class="toc-backref" href="#toc-entry-21">Contributors</a></h2>
588585
<ul class="simple">
589586
<li>Alexandre Fayolle &lt;<a class="reference external" href="mailto:alexandre.fayolle&#64;camptocamp.com">alexandre.fayolle&#64;camptocamp.com</a>&gt;</li>
590587
<li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt;</li>
@@ -593,7 +590,7 @@ <h3><a class="toc-backref" href="#toc-entry-21">Contributors</a></h3>
593590
</ul>
594591
</div>
595592
<div class="section" id="maintainers">
596-
<h3><a class="toc-backref" href="#toc-entry-22">Maintainers</a></h3>
593+
<h2><a class="toc-backref" href="#toc-entry-22">Maintainers</a></h2>
597594
<p>This module is maintained by the OCA.</p>
598595
<a class="reference external image-reference" href="https://odoo-community.org">
599596
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -608,6 +605,5 @@ <h3><a class="toc-backref" href="#toc-entry-22">Maintainers</a></h3>
608605
</div>
609606
</div>
610607
</div>
611-
</div>
612608
</body>
613609
</html>

auth_oidc/views/auth_oauth_provider.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<field name="jwks_uri" />
2121
<field name="end_session_endpoint" />
2222
</field>
23+
<field name="data_endpoint" position="after">
24+
<field name="disable_certificate_check" />
25+
<field name="ca_bundle" invisible="disable_certificate_check" />
26+
</field>
2327
</field>
2428
</record>
2529
</odoo>

0 commit comments

Comments
 (0)