-
-
Notifications
You must be signed in to change notification settings - Fork 543
[12.0][MIG] auth_ldaps #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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': [ | ||
| 'auth_ldap', | ||
| ], | ||
| 'external_dependencies': { | ||
| 'python': [ | ||
| 'ldap', | ||
| ], | ||
| }, | ||
| 'data': [ | ||
| 'views/res_company_ldap_views.xml', | ||
| ], | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.