Skip to content

Commit acdacb2

Browse files
committed
Merge PR #625 into 17.0
Signed-off-by dreispt
2 parents 838cf65 + 07f503c commit acdacb2

File tree

16 files changed

+658
-0
lines changed

16 files changed

+658
-0
lines changed

auth_admin_passkey/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ following keys in your ``odoo.cfg`` configuration file.
6363
- ``auth_admin_passkey_sysadmin_lang``. the language (exemple en_US),
6464
used for the mail sent to the System Administrator. If not set, the
6565
language of the SUPERUSER_ID user will be used.
66+
- ``auth_admin_passkey_ignore_totp`` (default False), if enabled, then
67+
2FA will be ignored.
6668

6769
**typical Dev / Test configuration section**
6870

auth_admin_passkey/models/res_users.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from datetime import datetime
88

99
from odoo import SUPERUSER_ID, _, api, exceptions, models
10+
from odoo.http import request
1011
from odoo.tools import config
1112

1213
logger = logging.getLogger(__name__)
@@ -74,6 +75,14 @@ def _check_credentials(self, password, env):
7475
password = hashlib.sha512(password.encode()).hexdigest()
7576

7677
if password and file_password == password:
78+
if request and hasattr(request, "session"):
79+
ignore_totp = config.get("auth_admin_passkey_ignore_totp", False)
80+
request.session["ignore_totp"] = ignore_totp
7781
self._send_email_passkey(users[0])
7882
else:
7983
raise
84+
85+
def _mfa_url(self):
86+
if request.session.get("ignore_totp"):
87+
return None
88+
return super()._mfa_url()

auth_admin_passkey/readme/CONFIGURE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ following keys in your `odoo.cfg` configuration file.
1515
- `auth_admin_passkey_sysadmin_lang`. the language (exemple en_US), used
1616
for the mail sent to the System Administrator. If not set, the
1717
language of the SUPERUSER_ID user will be used.
18+
- `auth_admin_passkey_ignore_totp` (default False), if enabled, then 2FA
19+
will be ignored.
1820

1921
**typical Dev / Test configuration section**
2022

auth_admin_passkey/static/description/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
412412
<li><tt class="docutils literal">auth_admin_passkey_sysadmin_lang</tt>. the language (exemple en_US),
413413
used for the mail sent to the System Administrator. If not set, the
414414
language of the SUPERUSER_ID user will be used.</li>
415+
<li><tt class="docutils literal">auth_admin_passkey_ignore_totp</tt> (default False), if enabled, then
416+
2FA will be ignored.</li>
415417
</ul>
416418
<p><strong>typical Dev / Test configuration section</strong></p>
417419
<p>No keys to add.</p>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
=========================================
2+
Authentification - Disable 2FA if Passkey
3+
=========================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:ed2a833d55c09a0f418a9b32605dacfd3cd3d126136d36943257f903dc050d79
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_admin_passkey_totp_mail_enforce
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_admin_passkey_totp_mail_enforce
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 is a glue module, needed to allow module auth_admin_passkey working
32+
properly in combination with auth_totp_mail_enforce.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Bug Tracker
40+
===========
41+
42+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
43+
In case of trouble, please check there if your issue has already been reported.
44+
If you spotted it first, help us to smash it by providing a detailed and welcomed
45+
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20auth_admin_passkey_totp_mail_enforce%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
46+
47+
Do not contact contributors directly about support or help with technical issues.
48+
49+
Credits
50+
=======
51+
52+
Authors
53+
-------
54+
55+
* 360ERP
56+
57+
Contributors
58+
------------
59+
60+
- [360ERP](https://www.360erp.com):
61+
62+
- Andrea Stirpe
63+
64+
Maintainers
65+
-----------
66+
67+
This module is maintained by the OCA.
68+
69+
.. image:: https://odoo-community.org/logo.png
70+
:alt: Odoo Community Association
71+
:target: https://odoo-community.org
72+
73+
OCA, or the Odoo Community Association, is a nonprofit organization whose
74+
mission is to support the collaborative development of Odoo features and
75+
promote its widespread use.
76+
77+
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/17.0/auth_admin_passkey_totp_mail_enforce>`_ project on GitHub.
78+
79+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 360ERP (<https://www.360erp.com>)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Authentification - Disable 2FA if Passkey",
6+
"summary": " Disable 2FA if Passkey is being used",
7+
"version": "17.0.1.0.0",
8+
"category": "base",
9+
"author": "360ERP,Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/server-auth",
11+
"license": "AGPL-3",
12+
"depends": ["auth_admin_passkey", "auth_totp_mail_enforce"],
13+
"installable": True,
14+
"auto_install": True,
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import res_users
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2024 360ERP (<https://www.360erp.com>)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
from odoo.http import request
6+
7+
8+
class ResUsers(models.Model):
9+
_inherit = "res.users"
10+
11+
def _mfa_url(self):
12+
"""Needed to ensure that 'ignore_totp' is processed before entering
13+
the _mfa_url() of auth_totp_mail_enforce.
14+
"""
15+
if request.session.get("ignore_totp"):
16+
return None
17+
return super()._mfa_url()
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"

0 commit comments

Comments
 (0)