Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions auth_ldaps/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

====================
LDAPS Authentication
====================

This module allows to authenticate using a LDAP over SSL system.

Installation
============

To verify LDAPS server certificate, you need to:

#. Add the CA certificate of the LDAPS on your server as a trusted certificate
#. Check the Verify certificate´ flag in configuration

Configuration
=============

To configure this module, you need to:

#. Access Settings / General Settings / LDAP Authentication / LDAP Server
#. Check the ´Use LDAPS´ flag

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/251/12.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/server-auth/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.

Contributors
------------

* Enric Tobella <etobella@creublanca.es>
* Alexey Pelykh <alexey.pelykh@brainbeanapps.com>

Do not contact contributors directly about support or help with technical issues.

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
3 changes: 3 additions & 0 deletions auth_ldaps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import models
29 changes: 29 additions & 0 deletions auth_ldaps/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (C) 2017 Creu Blanca
# Copyright (C) 2018 Brainbean Apps
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
'name': 'LDAPS authentication',
'version': '12.0.1.0.0',
'category': 'Tools',
'website': 'https://github.com/OCA/server-auth',
'author':
'Braibean Apps (https://brainbeanapps.com), '
'Creu Blanca, '
'Odoo Community Association (OCA)',
'license': 'AGPL-3',
'installable': True,
'application': False,
'summary': 'Allows to use LDAP over SSL authentication',
'depends': [
Comment thread
alexey-pelykh marked this conversation as resolved.
'auth_ldap',
],
'external_dependencies': {
'python': [
'ldap',
],
},
'data': [
'views/res_company_ldap_views.xml',
],
}
3 changes: 3 additions & 0 deletions auth_ldaps/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import res_company_ldap
48 changes: 48 additions & 0 deletions auth_ldaps/models/res_company_ldap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (C) Creu Blanca
# Copyright (C) 2018 Brainbean Apps
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

import logging
from odoo import fields, models

_logger = logging.getLogger(__name__)

try:
import ldap
except (ImportError) as err:
_logger.debug(err)


class CompanyLDAP(models.Model):
_inherit = 'res.company.ldap'
_description = 'Company LDAP configuration'

is_ssl = fields.Boolean(string='Use LDAPS', default=False)
skip_cert_validation = fields.Boolean(
string='Skip certificate validation',
default=False
)

def _get_ldap_dicts(self):
res = super()._get_ldap_dicts()
for rec in res:
ldap = self.sudo().browse(rec['id'])
rec['is_ssl'] = ldap.is_ssl or False
rec['skip_cert_validation'] = ldap.skip_cert_validation or False
return res

def _connect(self, conf):
if conf['is_ssl']:
uri = 'ldaps://%s:%d' % (
conf['ldap_server'], conf['ldap_server_port'])
connection = ldap.initialize(uri)
if conf['skip_cert_validation']:
connection.set_option(
ldap.OPT_X_TLS_REQUIRE_CERT,
ldap.OPT_X_TLS_ALLOW
)
connection.set_option(ldap.OPT_X_TLS_NEWCTX, 0)
if conf['ldap_tls']:
connection.start_tls_s()
return connection
return super()._connect(conf)
Binary file added auth_ldaps/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions auth_ldaps/views/res_company_ldap_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<!--
Copyright (C) 2017 Creu Blanca
Copyright (C) 2018 Brainbean Apps
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-->
<record id="view_ldap_installer_form" model="ir.ui.view">
<field name="name">res.company.ldap.form</field>
<field name="model">res.company.ldap</field>
<field name="inherit_id" ref="auth_ldap.view_ldap_installer_form"/>
<field name="arch" type="xml">
<field name="ldap_tls" position="after">
<field name="is_ssl"/>
<field name="skip_cert_validation"/>
</field>
</field>
</record>

</odoo>