← Back to Pull requests

[19.0][MIG] auth_admin_passkey #936

Merged
andrel-exo merged 38 files (2798 lines) on Nov 06, 2026 21:51 UTC
View on GitHub
andrel-exo andrel-exo commented on Apr 28, 2026 09:41 UTC
Author

No description provided by author.

Diff: 2798 lines (+2798 / -0) across 38 files Reviewer: legalsylvain Review duration: 277209m
All Vouch review confidence checks passed
Residual risk 0.31 = Change Risk (0.96) × (1 − Review Confidence (0.67)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.96 · 2798 lines diff across 38 files
0.96
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.34 · 5 substantive comment(s)
0.34
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
67%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Shallow Review Depth shallow_review_depth
0.230
Sensitive Paths sensitive_paths
0.096
Mass File Touch mass_file_touch
0.080
Empty Description empty_description
0.060
Real PR Conversation Timeline
16 items
legalsylvain legalsylvain commented on code on Apr 28, 2026 09:43 UTC
Code Review
auth_admin_passkey/models/res_users.py:1
@@ -61,7 +60,7 @@ def _check_credentials(self, credential, env):
 
         except exceptions.AccessDenied:
             # Just be sure that parent methods aren't wrong
-            users = self.with_user(SUPERUSER_ID).search([("id", "=", self._uid)])
+            users = self.with_user(SUPERUSER_ID).browse(self.env.uid).exists()

why .exists() ?

legalsylvain legalsylvain commented on Apr 28, 2026 09:44 UTC
Reviewer

a minor question.
thanks for porting this module !

andrel-exo andrel-exo commented on code on Apr 28, 2026 10:08 UTC
Code Review
auth_admin_passkey/models/res_users.py:1
@@ -61,7 +60,7 @@ def _check_credentials(self, credential, env):
 
         except exceptions.AccessDenied:
             # Just be sure that parent methods aren't wrong
-            users = self.with_user(SUPERUSER_ID).search([("id", "=", self._uid)])
+            users = self.with_user(SUPERUSER_ID).browse(self.env.uid).exists()

I added it to keep the existence check explicit after replacing search() with browse(), since browse() alone may return a non-existing record. But it changes the previous behavior compared to search(), so I’ll remove it and only replace self._uid with self.env.uid.

legalsylvain legalsylvain approved these changes on Apr 28, 2026 10:53 UTC
Approved Reviewer

Approved these changes.

atchuthan atchuthan approved these changes on Jun 05, 2026 08:04 UTC
Approved Reviewer

Functional & Tested in local 👍

OCA-git-bot OCA-git-bot commented on Jun 05, 2026 08:07 UTC
Bot

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

skanndar skanndar requested changes on Aug 05, 2026 19:21 UTC
Changes Requested Reviewer

Thanks for the migration — the port itself is faithful to 18.0. But I tested it on a clean 19.0 database with the odoo.conf documented in readme/CONFIGURE.md and none of the boolean keys work any more, including one that fails open. This is not something the migration introduced: 19.0 changed how the config file is read.

Root cause. Up to 18.0, configmanager._parse_config() cast 'True'/'False' to booleans for every key found in the [options] section. Since 19.0, _load_file_options() only parses the options it knows about and stores the rest as-is:

option = self.options_index.get(name)
if not option:
    ...
    "unknown option %r in the config file at %s, option stored as-is, without parsing"
    self._file_options[name] = value
    continue

All the auth_admin_passkey_ keys are unknown options, so they now arrive as strings — and "False" is truthy. Odoo even logs a warning for each of them at startup.

Setup: official odoo:19 image (build 19.0.20260723), fresh database, this PR's branch, and an odoo.conf with the documented keys:

auth_admin_passkey_password = masterkey
auth_admin_passkey_send_to_user = False
auth_admin_passkey_ignore_totp = False
auth_admin_passkey_password_sha512_encrypted = False

Every one of them is read as 'False' (str, truthy). Three observable consequences:

1. The passkey itself stops working. password_sha512_encrypted is truthy, so the typed password is sha512-hashed and compared against the plain masterkey from the config: _check_credentials() raises AccessDenied. With the documented configuration, the module's main feature is dead.

2. send_to_user = False is ignored. _send_email_passkey() still creates the mail.mail for the user (verified on the real method, one message created for the impersonated user).

3. ignore_totp = False enables the 2FA bypass. For a user with TOTP enabled:

| request.session["ignore_totp"] | _mfa_url() |
|---|---|
| not set | /web/login/totp |
| False (real boolean) | /web/login/totp |
| 'False' (what 19.0 gives) | None →
2FA skipped |

So an administrator who writes auth_admin_passkey_ignore_totp = False to make sure the bypass stays off gets exactly the opposite. That is the one I would not let through: the other two fail closed or are merely annoying, this one fails open.

I am reporting it here rather than through a private channel because the module is not in the 19.0 branch yet, so no one is running it on 19.0 — but it is worth fixing before the merge for that reason.

Suggested fix* — normalise the falsy strings where the config is read, e.g.:

_FALSY_CONFIG_VALUES = ("", "false", "none", "0")


def _get_config(key, default=False):
    value = config.get(key, default)
    if isinstance(value, str) and value.strip().lower() in _FALSY_CONFIG_VALUES:
        return False
    return value

and use it for the four keys. I have this running on two 19.0 databases (passkey login works, no notification when send_to_user = False, 2FA respected when ignore_totp = False, and the user's own password keeps working). Happy to push it here as a commit, with a test covering the three cases, if you prefer.

Worth keeping in mind for other migrations too: any module reading its own boolean keys from odoo.conf with config.get() has the same problem on 19.0.

SiscoIngeos SiscoIngeos commented on Aug 13, 2026 10:30 UTC
Contributor

LGTM

andrel-exo andrel-exo commented on Aug 13, 2026 11:21 UTC
Author

Thanks for the detailed report, the root cause is correct and I could reproduce it on 19.0. Fixed in c5c3325.

I used Odoo's own str2bool instead of a custom list of falsy strings: it exists in both 18.0 and 19.0, accepts booleans and strings, and takes a default for unparsable values. Applied to the three boolean keys only (send_to_user, password_sha512_encrypted, ignore_totp), auth_admin_passkey_password stays a raw string.

Added four tests that assign the raw strings the module gets from the config file, instead of Python booleans as the existing tests do. They fail without the fix and pass with it, verified on a real 19.0 instance with the keys set in odoo.conf.

@legalsylvain @atchuthan sorry for the noise, this needs a new look since you already approved.

skanndar skanndar approved these changes on Aug 14, 2026 13:10 UTC
Approved Reviewer

Re-tested c5c3325 on a clean 19.0 database with the same setup as my report — official odoo:19 image, real odoo.conf (not values injected into config at runtime, since the file-parsing path is what changed in 19.0), auth_totp installed. All three issues are gone:

| With = False in odoo.conf | before | now |
|---|---|---|
| password_sha512_encrypted → passkey login | AccessDenied | works |
| send_to_user → email to the impersonated user | sent | not sent (and the sysadmin one still goes out) |
| ignore_totp → _mfa_url() for a TOTP user | None, 2FA skipped | /web/login/totp, 2FA enforced |

For the third one I kept the controls from the report: no session flag and a real False boolean both give /web/login/totp, and now the value coming from the config file does too.

str2bool is the better call — thanks for not taking my falsy-list as-is. I also checked the edges: an unparsable value falls back to the given default (ignore_totp → False, so 2FA stays on; send_to_user → True, so the notification stays on — both fail the safe way), and an absent key still works since str2bool accepts the boolean default itself. Applying it only to the three boolean keys and leaving sysadmin_email / sysadmin_lang / password alone is right.

Tests 12-15 cover exactly the three cases plus the positive one; the module suite is green here (20 tests).

LGTM 👍

OCA-git-bot OCA-git-bot commented on Aug 14, 2026 14:00 UTC
Bot

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

atchuthan atchuthan approved these changes on Nov 06, 2026 07:28 UTC
Approved Reviewer

Approved these changes.

legalsylvain legalsylvain commented on Nov 06, 2026 21:44 UTC
Reviewer

/ocabot merge nobump

OCA-git-bot OCA-git-bot commented on Nov 06, 2026 21:44 UTC
Bot

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 19.0-ocabot-merge-pr-936-by-legalsylvain-bump-nobump, awaiting test results.

OCA-git-bot OCA-git-bot commented on Nov 06, 2026 21:51 UTC
Bot

Congratulations, your PR was merged at ffbad2cbffb26f47f78f813b33377fe88045e9f3. Thanks a lot for contributing to OCA. ❤️

Reviewers
Assignees
andrel-exo andrel-exo
Labels
risk: low confidence: 67.5% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 96% (HIGH) · Higher = larger blast radius
96%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 67.5% · Lower = rushed or shallow review
67.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 31.2% · Safe to merge
31.2%