Browse Source

Merge pull request #455 from Noviat/80-server-tools-ldap-only-fix

only ldap groups fix
pull/279/merge
Yannick Vaucher 7 years ago
committed by GitHub
parent
commit
6c20ccf631
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      users_ldap_groups/README.rst
  2. 22
      users_ldap_groups/__init__.py
  3. 2
      users_ldap_groups/__openerp__.py
  4. 3
      users_ldap_groups/models/__init__.py
  5. 51
      users_ldap_groups/models/res_users.py
  6. 0
      users_ldap_groups/models/users_ldap_groups.py

1
users_ldap_groups/README.rst

@ -47,6 +47,7 @@ Contributors
* Therp BV <info@therp.nl> * Therp BV <info@therp.nl>
* Giacomo Spettoli <giacomo.spettoli@gmail.com> * Giacomo Spettoli <giacomo.spettoli@gmail.com>
* Luc De Meyer <luc.demeyer@noviat.com>
Maintainer Maintainer
---------- ----------

22
users_ldap_groups/__init__.py

@ -1,22 +1,2 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2012 Therp BV (<http://therp.nl>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import users_ldap_groups
from . import models

2
users_ldap_groups/__openerp__.py

@ -21,7 +21,7 @@
{ {
"name": "Groups assignment", "name": "Groups assignment",
"version": "8.0.1.2.1",
"version": "8.0.1.2.2",
"depends": ["auth_ldap"], "depends": ["auth_ldap"],
"author": "Therp BV,Odoo Community Association (OCA)", "author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",

3
users_ldap_groups/models/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import users_ldap_groups
from . import res_users

51
users_ldap_groups/models/res_users.py

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Management Solution
#
# Copyright (c) 2009-2016 Noviat nv/sa (www.noviat.com).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import api, models
from openerp import SUPERUSER_ID
from openerp.modules.registry import RegistryManager
class ResUsers(models.Model):
_inherit = 'res.users'
def _login(self, db, login, password):
"""
Call map_groups also for existing users
in order to enforce the 'only_ldap_groups'
security policy.
"""
uid = super(ResUsers, self)._login(db, login, password)
if uid:
registry = RegistryManager.get(db)
with registry.cursor() as cr:
ldap_obj = registry.get('res.company.ldap')
for ldap_config in ldap_obj.get_ldap_dicts(cr):
ldap_entry = ldap_obj.authenticate(
ldap_config, login, password)
if ldap_entry:
env = api.Environment(cr, SUPERUSER_ID, {})
comp_ldap = env['res.company.ldap'].browse(
ldap_config['id'])
comp_ldap.map_groups(
uid, ldap_config, ldap_entry)
return uid

0
users_ldap_groups/users_ldap_groups.py → users_ldap_groups/models/users_ldap_groups.py

Loading…
Cancel
Save