Skip to content

Commit 1bdc7db

Browse files
committed
Merge PR #643 into 17.0
Signed-off-by pedrobaeza
2 parents def9106 + 1337793 commit 1bdc7db

18 files changed

Lines changed: 785 additions & 0 deletions

auth_ldaps/README.rst

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
====================
2+
LDAPS authentication
3+
====================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:d0479aff742f2c5f5ff1bfa5a7de7ac307a3d04a5763dbe003aad01cbbd4c393
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
20+
:target: https://github.com/OCA/server-auth/tree/17.0/auth_ldaps
21+
:alt: OCA/server-auth
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-auth_ldaps
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows to authenticate using a LDAP over SSL system.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Installation
39+
============
40+
41+
To verify LDAPS server certificate, you need to:
42+
43+
1. Add the CA certificate of the LDAPS on your server as a trusted
44+
certificate
45+
2. Check the ``Verify certificate`` flag in configuration
46+
47+
Configuration
48+
=============
49+
50+
To configure this module, you need to:
51+
52+
1. Access Settings / General Settings / LDAP Authentication / LDAP
53+
Server
54+
2. Check the ``Use LDAPS`` flag
55+
56+
Usage
57+
=====
58+
59+
60+
61+
Bug Tracker
62+
===========
63+
64+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
65+
In case of trouble, please check there if your issue has already been reported.
66+
If you spotted it first, help us to smash it by providing a detailed and welcomed
67+
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20auth_ldaps%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
68+
69+
Do not contact contributors directly about support or help with technical issues.
70+
71+
Credits
72+
=======
73+
74+
Authors
75+
-------
76+
77+
* CorporateHub
78+
* Creu Blanca
79+
80+
Contributors
81+
------------
82+
83+
- Enric Tobella <etobella@creublanca.es>
84+
85+
- `CorporateHub <https://corporatehub.eu/>`__
86+
87+
- Alexey Pelykh <alexey.pelykh@corphub.eu>
88+
89+
- Bhavesh Odedra <bodedra@opensourceintegrators.com>
90+
91+
- `Trobz <https://trobz.com>`__:
92+
93+
- Hoang Diep <hoang@trobz.com>
94+
95+
Other credits
96+
-------------
97+
98+
The migration of this module from 15.0 to 16.0 was financially supported
99+
by Camptocamp
100+
101+
Maintainers
102+
-----------
103+
104+
This module is maintained by the OCA.
105+
106+
.. image:: https://odoo-community.org/logo.png
107+
:alt: Odoo Community Association
108+
:target: https://odoo-community.org
109+
110+
OCA, or the Odoo Community Association, is a nonprofit organization whose
111+
mission is to support the collaborative development of Odoo features and
112+
promote its widespread use.
113+
114+
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/17.0/auth_ldaps>`_ project on GitHub.
115+
116+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

auth_ldaps/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
2+
3+
from . import models

auth_ldaps/__manifest__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (C) 2017 Creu Blanca
2+
# Copyright (C) 2018 Brainbean Apps
3+
# Copyright 2020 CorporateHub (https://corporatehub.eu)
4+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
5+
6+
{
7+
"name": "LDAPS authentication",
8+
"version": "17.0.1.0.0",
9+
"category": "Tools",
10+
"website": "https://github.com/OCA/server-auth",
11+
"author": "CorporateHub, " "Creu Blanca, " "Odoo Community Association (OCA)",
12+
"license": "AGPL-3",
13+
"installable": True,
14+
"application": False,
15+
"summary": "Allows to use LDAP over SSL authentication",
16+
"depends": ["auth_ldap"],
17+
"data": ["views/res_company_ldap_views.xml"],
18+
"external_dependencies": {"python": ["python-ldap"]},
19+
}

auth_ldaps/i18n/auth_ldaps.pot

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * auth_ldaps
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: auth_ldaps
17+
#: model:ir.model,name:auth_ldaps.model_res_company_ldap
18+
msgid "Company LDAP configuration"
19+
msgstr ""
20+
21+
#. module: auth_ldaps
22+
#: model:ir.model.fields,field_description:auth_ldaps.field_res_company_ldap__skip_cert_validation
23+
msgid "Skip certificate validation"
24+
msgstr ""
25+
26+
#. module: auth_ldaps
27+
#: model:ir.model.fields,field_description:auth_ldaps.field_res_company_ldap__is_ssl
28+
msgid "Use LDAPS"
29+
msgstr ""

auth_ldaps/i18n/it.po

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * auth_ldaps
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 14.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2021-03-02 19:45+0000\n"
10+
"Last-Translator: Sergio Zanchetta <primes2h@gmail.com>\n"
11+
"Language-Team: none\n"
12+
"Language: it\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
17+
"X-Generator: Weblate 4.3.2\n"
18+
19+
#. module: auth_ldaps
20+
#: model:ir.model,name:auth_ldaps.model_res_company_ldap
21+
msgid "Company LDAP configuration"
22+
msgstr "Configurazione LDAP azienda"
23+
24+
#. module: auth_ldaps
25+
#: model:ir.model.fields,field_description:auth_ldaps.field_res_company_ldap__skip_cert_validation
26+
msgid "Skip certificate validation"
27+
msgstr "Saltare verifica del certificato"
28+
29+
#. module: auth_ldaps
30+
#: model:ir.model.fields,field_description:auth_ldaps.field_res_company_ldap__is_ssl
31+
msgid "Use LDAPS"
32+
msgstr "Utilizzare LDAPS"
33+
34+
#~ msgid "Display Name"
35+
#~ msgstr "Nome visualizzato"
36+
37+
#~ msgid "ID"
38+
#~ msgstr "ID"
39+
40+
#~ msgid "Last Modified on"
41+
#~ msgstr "Ultima modifica il"

auth_ldaps/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
2+
3+
from . import res_company_ldap
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (C) Creu Blanca
2+
# Copyright (C) 2018 Brainbean Apps
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
4+
5+
6+
import logging
7+
8+
import ldap
9+
10+
from odoo import fields, models
11+
from odoo.tools.misc import str2bool
12+
13+
_logger = logging.getLogger(__name__)
14+
15+
16+
class CompanyLDAP(models.Model):
17+
_inherit = "res.company.ldap"
18+
19+
is_ssl = fields.Boolean(string="Use LDAPS", default=False)
20+
skip_cert_validation = fields.Boolean(
21+
string="Skip certificate validation", default=False
22+
)
23+
24+
def _get_ldap_dicts(self):
25+
res = super()._get_ldap_dicts()
26+
for rec in res:
27+
ldap = self.sudo().browse(rec["id"])
28+
rec["is_ssl"] = ldap.is_ssl or False
29+
rec["skip_cert_validation"] = ldap.skip_cert_validation or False
30+
return res
31+
32+
def _connect(self, conf):
33+
if conf["is_ssl"]:
34+
uri = "ldaps://%s:%d" % (conf["ldap_server"], conf["ldap_server_port"])
35+
connection = ldap.initialize(uri)
36+
ldap_chase_ref_disabled = (
37+
self.env["ir.config_parameter"]
38+
.sudo()
39+
.get_param("auth_ldap.disable_chase_ref")
40+
)
41+
if str2bool(ldap_chase_ref_disabled):
42+
connection.set_option(ldap.OPT_REFERRALS, ldap.OPT_OFF)
43+
if conf["skip_cert_validation"]:
44+
connection.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)
45+
# this creates a new tls context, which is required to apply
46+
# the options, but it also clears the default options defined
47+
# in the openldap's configuration file, such as the TLS_CACERT
48+
# option, which specifies the file containing the trusted
49+
# certificates. this causes certificate verification to fail,
50+
# even if it would succeed with the default options. this is
51+
# why this is only called if we want to skip certificate
52+
# verification.
53+
connection.set_option(ldap.OPT_X_TLS_NEWCTX, 0)
54+
if conf["ldap_tls"]:
55+
connection.start_tls_s()
56+
return connection
57+
return super()._connect(conf)

auth_ldaps/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"

auth_ldaps/readme/CONFIGURE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
To configure this module, you need to:
2+
3+
1. Access Settings / General Settings / LDAP Authentication / LDAP
4+
Server
5+
2. Check the `Use LDAPS` flag

auth_ldaps/readme/CONTRIBUTORS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- Enric Tobella \<<etobella@creublanca.es>\>
2+
3+
- [CorporateHub](https://corporatehub.eu/)
4+
5+
- Alexey Pelykh \<<alexey.pelykh@corphub.eu>\>
6+
7+
- Bhavesh Odedra \<<bodedra@opensourceintegrators.com>\>
8+
9+
- [Trobz](https://trobz.com):
10+
11+
> - Hoang Diep \<<hoang@trobz.com>\>

0 commit comments

Comments
 (0)