Skip to content

Commit 72254ae

Browse files
committed
auth_admin_passkey: Migrate module for odoo 10
Remove authenticate as check_credentials is dedicated for this purpose. Removed mail translations maybe possible in some way ? Give some space to the code Make the addon compliant to OCA guidelines Adapt readme to new template and compress header in tests Make the addon a python package NOTE: authenticate() method cannot be used in tests because a new cr is created in _login method that does not contains our user. Signed-off-by: Eugen Don <eugen.don@don-systems.de>
1 parent 20d4138 commit 72254ae

File tree

15 files changed

+442
-326
lines changed

15 files changed

+442
-326
lines changed

auth_admin_passkey/README.rst

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,80 @@
1-
Admin password become a passkey for all active logins
2-
=====================================================
3-
4-
Functionality :
5-
---------------
6-
* Administrator has now the possibility to login in with any login;
7-
* By default, Odoo will send a mail to user and admin to indicate them;
8-
* If a user and the admin have the same password, admin will be informed;
9-
10-
Technical information :
11-
-----------------------
12-
* Create two ir_config_parameter to enable / disable mail sending;
13-
14-
Copyright, Author and Licence :
15-
-------------------------------
16-
* Copyright : 2014, Groupement Régional Alimentaire de Proximité;
17-
* Author : Sylvain LE GAL (https://twitter.com/legalsylvain);
18-
* Licence : AGPL-3 (http://www.gnu.org/licenses/)
1+
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
3+
:alt: License: AGPL-3
4+
5+
====================
6+
Auth Admin - Passkey
7+
====================
8+
9+
This module extends the functionality of users module to support loging in with the administrator password
10+
in other user accounts.
11+
12+
* Administrator has now the possibility to login in with any login;
13+
* By default, Odoo will send a mail to user and admin to indicate them;
14+
* If a user and the admin have the same password, admin will be informed;
15+
16+
17+
Configuration
18+
=============
19+
20+
To enable notifications for login attempts, you need to:
21+
22+
Go to Settings > General Settings.
23+
24+
Enable the "Send email to admin user" and / or "Send email to user" checkbox
25+
26+
27+
Usage
28+
=====
29+
30+
To login into a different user account type in the user name of the account and the password of the administrator at the login screen
31+
32+
33+
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
34+
:alt: Try me on Runbot
35+
:target: https://runbot.odoo-community.org/runbot/149/10.0
36+
37+
38+
Known issues / Roadmap
39+
======================
40+
41+
None
42+
43+
Bug Tracker
44+
===========
45+
46+
Bugs are tracked on `GitHub Issues
47+
<https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
48+
check there if your issue has already been reported. If you spotted it first,
49+
help us smash it by providing detailed and welcomed feedback.
50+
51+
Credits
52+
=======
53+
54+
Images
55+
------
56+
57+
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
58+
59+
Contributors
60+
------------
61+
62+
* Eugen Don <eugen.don@don-systems.de>
63+
* Alexandre Papin (https://twitter.com/Fenkiou)
64+
* Sylvain LE GAL (https://twitter.com/legalsylvain)
65+
66+
67+
Maintainer
68+
----------
69+
70+
.. image:: https://odoo-community.org/logo.png
71+
:alt: Odoo Community Association
72+
:target: https://odoo-community.org
73+
74+
This module is maintained by the OCA.
75+
76+
OCA, or the Odoo Community Association, is a nonprofit organization whose
77+
mission is to support the collaborative development of Odoo features and
78+
promote its widespread use.
79+
80+
To contribute to this module, please visit https://odoo-community.org.

auth_admin_passkey/__manifest__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
{
77
'name': 'Authentification - Admin Passkey',
8-
'version': '8.0.2.1.1',
8+
'version': '10.0.1.0.0',
99
'category': 'base',
1010
'author': "GRAP,Odoo Community Association (OCA)",
1111
'website': 'http://www.grap.coop',
1212
'license': 'AGPL-3',
1313
'depends': [
1414
'mail',
15-
],
15+
],
1616
'data': [
1717
'data/ir_config_parameter.xml',
1818
'views/res_config_view.xml',
@@ -24,6 +24,6 @@
2424
'images': [],
2525
'post_load': '',
2626
'application': False,
27-
'installable': False,
27+
'installable': True,
2828
'auto_install': False,
2929
}
Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!-- ********************************************************************** -->
3-
<!--Admin Passkey module for Odoo -->
4-
<!--Copyright (C) 2013-2014 GRAP (http://www.grap.coop) -->
5-
<!--@author Sylvain LE GAL (https://twitter.com/legalsylvain) -->
6-
7-
<!--This program is free software: you can redistribute it and/or modify -->
8-
<!--it under the terms of the GNU Affero General Public License as -->
9-
<!--published by the Free Software Foundation, either version 3 of the -->
10-
<!--License, or (at your option) any later version. -->
11-
12-
<!--This program is distributed in the hope that it will be useful, -->
13-
<!--but WITHOUT ANY WARRANTY; without even the implied warranty of -->
14-
<!--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
15-
<!--GNU Affero General Public License for more details. -->
16-
17-
<!--You should have received a copy of the GNU Affero General Public License-->
18-
<!--along with this program. If not, see <http://www.gnu.org/licenses/>. -->
19-
<!-- ********************************************************************** -->
20-
<openerp>
2+
<odoo>
213
<data noupdate="1">
224

235
<record id="send_to_admin" model="ir.config_parameter">
@@ -31,4 +13,4 @@
3113
</record>
3214

3315
</data>
34-
</openerp>
16+
</odoo>

auth_admin_passkey/i18n/auth_admin_passkey.pot

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
1-
##############################################################################
2-
#
3-
# Admin Passkey module for Odoo
4-
# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
5-
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
6-
#
7-
# This program is free software: you can redistribute it and/or modify
8-
# it under the terms of the GNU Affero General Public License as
9-
# published by the Free Software Foundation, either version 3 of the
10-
# License, or (at your option) any later version.
11-
#
12-
# This program is distributed in the hope that it will be useful,
13-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
# GNU Affero General Public License for more details.
16-
#
17-
# You should have received a copy of the GNU Affero General Public License
18-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19-
#
20-
##############################################################################
21-
# Translation of OpenERP Server.
1+
# Translation of Odoo Server.
222
# This file contains the translation of the following modules:
233
# * auth_admin_passkey
244
#
255
msgid ""
266
msgstr ""
27-
"Project-Id-Version: OpenERP Server 7.0\n"
7+
"Project-Id-Version: Odoo Server 10.0\n"
288
"Report-Msgid-Bugs-To: \n"
29-
"POT-Creation-Date: 2014-03-23 20:41+0000\n"
30-
"PO-Revision-Date: 2014-03-23 20:41+0000\n"
9+
"POT-Creation-Date: 2017-03-15 19:43+0000\n"
10+
"PO-Revision-Date: 2017-03-15 19:43+0000\n"
3111
"Last-Translator: <>\n"
3212
"Language-Team: \n"
3313
"MIME-Version: 1.0\n"
@@ -36,13 +16,13 @@ msgstr ""
3616
"Plural-Forms: \n"
3717

3818
#. module: auth_admin_passkey
39-
#: code:addons/auth_admin_passkey/model/res_users.py:66
19+
#: code:addons/auth_admin_passkey/models/res_users.py:64
4020
#, python-format
4121
msgid "<pre>User with login '%s' has the same password as you.</pre>"
4222
msgstr ""
4323

4424
#. module: auth_admin_passkey
45-
#: code:addons/auth_admin_passkey/model/res_users.py:44
25+
#: code:addons/auth_admin_passkey/models/res_users.py:39
4626
#, python-format
4727
msgid "Admin user used his passkey to login with '%s'.\n"
4828
"\n"
@@ -56,45 +36,43 @@ msgid "Admin user used his passkey to login with '%s'.\n"
5636
msgstr ""
5737

5838
#. module: auth_admin_passkey
59-
#: view:base.config.settings:0
39+
#: model:ir.ui.view,arch_db:auth_admin_passkey.view_res_config_settings
6040
msgid "Passkey"
6141
msgstr ""
6242

6343
#. module: auth_admin_passkey
64-
#: code:addons/auth_admin_passkey/model/res_users.py:42
44+
#: code:addons/auth_admin_passkey/models/res_users.py:38
6545
#, python-format
6646
msgid "Passkey used"
6747
msgstr ""
6848

6949
#. module: auth_admin_passkey
70-
#: field:base.config.settings,auth_admin_passkey_send_to_admin:0
50+
#: model:ir.model.fields,field_description:auth_admin_passkey.field_base_config_settings_auth_admin_passkey_send_to_admin
7151
msgid "Send email to admin user."
7252
msgstr ""
7353

7454
#. module: auth_admin_passkey
75-
#: field:base.config.settings,auth_admin_passkey_send_to_user:0
55+
#: model:ir.model.fields,field_description:auth_admin_passkey.field_base_config_settings_auth_admin_passkey_send_to_user
7656
msgid "Send email to user."
7757
msgstr ""
7858

7959
#. module: auth_admin_passkey
80-
#: code:_description:0
8160
#: model:ir.model,name:auth_admin_passkey.model_res_users
82-
#, python-format
8361
msgid "Users"
8462
msgstr ""
8563

8664
#. module: auth_admin_passkey
87-
#: help:base.config.settings,auth_admin_passkey_send_to_user:0
65+
#: model:ir.model.fields,help:auth_admin_passkey.field_base_config_settings_auth_admin_passkey_send_to_user
8866
msgid "When the administrator use his password to login in with a different account, Odoo will send an email to the account user."
8967
msgstr ""
9068

9169
#. module: auth_admin_passkey
92-
#: help:base.config.settings,auth_admin_passkey_send_to_admin:0
70+
#: model:ir.model.fields,help:auth_admin_passkey.field_base_config_settings_auth_admin_passkey_send_to_admin
9371
msgid "When the administrator use his password to login in with a different account, Odoo will send an email to the admin user."
9472
msgstr ""
9573

9674
#. module: auth_admin_passkey
97-
#: code:addons/auth_admin_passkey/model/res_users.py:64
75+
#: code:addons/auth_admin_passkey/models/res_users.py:62
9876
#, python-format
9977
msgid "[WARNING] Odoo Security Risk"
10078
msgstr ""
Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
1-
# -*- encoding: utf-8 -*-
2-
##############################################################################
3-
#
4-
# Admin Passkey module for Odoo
5-
# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
6-
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
7-
#
8-
# This program is free software: you can redistribute it and/or modify
9-
# it under the terms of the GNU Affero General Public License as
10-
# published by the Free Software Foundation, either version 3 of the
11-
# License, or (at your option) any later version.
12-
#
13-
# This program is distributed in the hope that it will be useful,
14-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16-
# GNU Affero General Public License for more details.
17-
#
18-
# You should have received a copy of the GNU Affero General Public License
19-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20-
#
21-
##############################################################################
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
3+
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
4+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
225

23-
from . import res_config
24-
from . import res_users
6+
from . import (
7+
res_config,
8+
res_users,
9+
)

auth_admin_passkey/models/res_config.py

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,56 @@
33
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
44
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
55

6-
from openerp import api, fields, models
6+
from odoo import api, fields, models
7+
from odoo.tools import safe_eval
78

89

910
class BaseConfigSettings(models.TransientModel):
1011
_inherit = 'base.config.settings'
1112

12-
# Getter / Setter Section
1313
@api.model
1414
def get_default_auth_admin_passkey_send_to_admin(self, fields):
15+
icp = self.env['ir.config_parameter']
1516
return {
16-
'auth_admin_passkey_send_to_admin':
17-
self.env["ir.config_parameter"].get_param(
18-
"auth_admin_passkey.send_to_admin")
17+
'auth_admin_passkey_send_to_admin': safe_eval(icp.get_param(
18+
'auth_admin_passkey.send_to_admin', 'True')),
1919
}
2020

21-
@api.multi
22-
def set_auth_admin_passkey_send_to_admin(self):
23-
for config in self:
24-
self.env['ir.config_parameter'].set_param(
25-
"auth_admin_passkey.send_to_admin",
26-
config.auth_admin_passkey_send_to_admin or '')
27-
2821
@api.model
2922
def get_default_auth_admin_passkey_send_to_user(self, fields):
23+
icp = self.env['ir.config_parameter']
3024
return {
31-
'auth_admin_passkey_send_to_user':
32-
self.env["ir.config_parameter"].get_param(
33-
"auth_admin_passkey.send_to_user")
25+
'auth_admin_passkey_send_to_user': safe_eval(icp.get_param(
26+
'auth_admin_passkey.send_to_user', 'True')),
3427
}
3528

36-
@api.multi
37-
def set_auth_admin_passkey_send_to_user(self):
38-
for config in self:
39-
self.env['ir.config_parameter'].set_param(
40-
"auth_admin_passkey.send_to_user",
41-
config.auth_admin_passkey_send_to_user or '')
42-
4329
auth_admin_passkey_send_to_admin = fields.Boolean(
44-
string='Send email to admin user.',
45-
help="""When the administrator use his password to login in """
46-
"""with a different account, Odoo will send an email """
47-
"""to the admin user.""")
48-
30+
'Send email to admin user.',
31+
help=('When the administrator use his password to login in '
32+
'with a different account, Odoo will send an email '
33+
'to the admin user.'),
34+
)
4935
auth_admin_passkey_send_to_user = fields.Boolean(
5036
string='Send email to user.',
51-
help="""When the administrator use his password to login in """
52-
"""with a different account, Odoo will send an email """
53-
"""to the account user.""")
37+
help=('When the administrator use his password to login in '
38+
'with a different account, Odoo will send an email '
39+
'to the account user.'),
40+
)
41+
42+
@api.multi
43+
def set_auth_admin_passkey_send_to_admin(self):
44+
self.ensure_one()
45+
46+
icp = self.env['ir.config_parameter']
47+
icp.set_param(
48+
'auth_admin_passkey.send_to_admin',
49+
repr(self.auth_admin_passkey_send_to_admin))
50+
51+
@api.multi
52+
def set_auth_admin_passkey_send_to_user(self):
53+
self.ensure_one()
54+
55+
icp = self.env['ir.config_parameter']
56+
icp.set_param(
57+
'auth_admin_passkey.send_to_user',
58+
repr(self.auth_admin_passkey_send_to_user))

0 commit comments

Comments
 (0)