Skip to content
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

[IMP] added option for TOTP/2FA bypass for admin passkey #550

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions auth_admin_passkey/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ following keys in your ``odoo.cfg`` configuration file.
* ``auth_admin_passkey_password``. The password that allows user to logging in
with any login. If not set, the feature is disabled.

* ``auth_admin_passkey_ignore_totp`` (default False), if enabled, then 2FA will be ignored.

* ``auth_admin_passkey_password_sha512_encrypted`` (default False), if enabled,
auth_admin_passkey_password should be the password encrypted with sha512.
On linux, this can be done using this command:
Expand Down
7 changes: 7 additions & 0 deletions auth_admin_passkey/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from odoo import SUPERUSER_ID, _, api, exceptions, models
from odoo.tools import config
from odoo.http import request

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -74,6 +75,12 @@ def _check_credentials(self, password, env):
password = hashlib.sha512(password.encode()).hexdigest()

if password and file_password == password:
request.session['ignore_totp'] = config.get("auth_admin_passkey_ignore_totp", False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codeagencybe

I ported your PR to V17, here: #624

To make the existing tests passing with success, I added this change f138da2
This way we avoid that the session is being written if it's not existing.

I think you need to implement the same here as well.

self._send_email_passkey(users[0])
else:
raise

def _mfa_url(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module should inherit auth_totp_mail_enforce to bypass.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an alternative to inheriting auth_totp_mail_enforce, we could make use of a glue module to combine this PR and auth_totp_mail_enforce. Here is a proposal of a glue module for V17: #625

if request.session.get('ignore_totp'):
return None
return super()._mfa_url()
Loading