Skip to content

[20.0][IMP] auth_signup_verify_email: review suggestions for OCA/server-auth#1064 - #2

Open
weinni2000 wants to merge 1 commit into
20.0-mig-auth_signup_verify_emailfrom
20.0-auth_signup_verify_email-review-fixes
Open

weinni2000 wants to merge 1 commit into
20.0-mig-auth_signup_verify_emailfrom
20.0-auth_signup_verify_email-review-fixes

Conversation

@weinni2000

@weinni2000 weinni2000 commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

These are the changes suggested in the review of OCA#1064, on top of its head (710aa593).

  • Allow-list the signup values: passwordless_signup passed all of request.params to res.users.sudo().signup(). Without a token, that ends in template_user.copy(values), so any posted field (including partner fields through _inherits) was set on the new user. Now only login, name, email and an empty password are passed.
  • Core's guards: the passwordless path skipped core's 404 when signup is disabled and its handling of an invalid token. Both are now checked first.
  • Unambiguous password xpath: in 20.0, auth_signup.fields nests a second div.field-password inside div.field-confirm_password. The xpath now also requires label[@for='password'].
  • Removed signup_login_fields: core 20.0 already renders type="email" on the signup login input.
  • Tests:
    • the signup page shows no password fields
    • extra POST params (ref) don't reach the user
    • signup disabled returns 404
    • removed the duplicate patch import

About the upgrade script from OCA#1034: it removes stale website-specific copies of auth_signup.signup, which break validation of this module's view that inherits it. That view was signup_login_fields, which this PR removes. The only remaining view inherits auth_signup.fields, so no script is needed.

Checks: pre-commit passes on the changed files. I didn't run the Odoo tests locally; CI on OCA#1064 will run them once these changes are applied there.

🤖 Generated with Claude Code

Summary by Sourcery

Harden passwordless signup by aligning it with core signup guards, limiting accepted fields, and refining its signup form behavior.

Bug Fixes:

  • Restrict passwordless signup to approved user fields and preserve core handling for disabled signup and invalid tokens.
  • Correctly target the password field in the signup view so password inputs remain hidden on passwordless signup.

Enhancements:

  • Remove the redundant signup login-field override now that core provides email input handling.

Tests:

  • Add coverage for hidden password fields, ignored extra parameters, and the disabled-signup 404 response.

Chores:

  • Simplify test setup and remove the duplicate mock import.

- Build the signup values from an allow-list instead of passing all
  request params to the sudo signup (they end up in copy() of the
  template user).
- Apply core's guards before the passwordless signup: 404 when signup
  is disabled, render the error on an invalid token.
- Make the password xpath unambiguous: in 20.0 a second
  div.field-password is nested inside div.field-confirm_password.
- Drop signup_login_fields: core 20.0 already uses type="email".
- Tests: signup page hides the password fields, extra params are
  ignored, 404 when signup is disabled; drop the duplicate import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Guard passwordless signup using core’s checks and pass only the intended signup fields, preventing arbitrary request parameters from being copied onto the new user.

  • auth_signup_verify_email/controllers/main.py L26-36, L51-58, L64-68 (+2 small edits)

UI

Make the password-field xpath target the intended field and remove the login-input override already provided by core.

  • auth_signup_verify_email/views/signup.xml L6-9, L16 (removed lines)

Tests

Update test setup and add coverage for hidden password fields, ignored extra signup parameters, and disabled signup.

  • auth_signup_verify_email/tests/test_verify_email.py L23-31, L43-49, L63-83 (+2 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="auth_signup_verify_email/controllers/main.py" line_range="56" />
<code_context>
+        values = {
+            "login": login,
+            "name": request.params.get("name"),
+            "email": request.params.get("email") or login,
+            "password": "",
+        }
</code_context>
<issue_to_address>
**Unverified login addresses can be claimed**

When an unauthenticated caller submits a valid, unclaimed victim address as `login` and an attacker-controlled address as `email` while public signup is enabled, `passwordless_signup` validates `login` but stores the caller-supplied `email`; `reset_password(login)` then sends the activation link to that stored address. An attacker can register an unclaimed victim address as the login while receiving its activation link, enabling identity squatting and impersonation.

Set the signup email to the validated login, or validate that any separately accepted email is the same address whose ownership must be verified.
</issue_to_address>

### Comment 2
<location path="auth_signup_verify_email/controllers/main.py" line_range="27-30" />
<code_context>
         qcontext = self.get_auth_signup_qcontext()

+        # Same guards as core's web_auth_signup
+        if not qcontext.get("token") and not qcontext.get("signup_enabled"):
+            raise NotFound()
+        if qcontext.get("error"):
+            return request.render("auth_signup.signup", qcontext)
+
+        login = request.params.get("login", "")
</code_context>
<issue_to_address>
**GET requests create accounts**

When signup is enabled and a GET request includes a `login` parameter but no `password`, `web_auth_signup` sends any request with a `login` and no `password` to `passwordless_signup`, which proceeds to `signup()` without checking the HTTP method. A GET request can therefore create an account and send an activation email instead of only displaying the signup form.

Only run passwordless signup for POST requests; render the signup page for GET requests.
</issue_to_address>

### Comment 3
<location path="auth_signup_verify_email/controllers/main.py" line_range="55" />
<code_context>
+        # params go to a sudo copy() of the template user
+        values = {
+            "login": login,
+            "name": request.params.get("name"),
+            "email": request.params.get("email") or login,
+            "password": "",
</code_context>
<issue_to_address>
**Signup rejects missing names**

When a signup POST omits the `name` parameter, `request.params.get("name")` adds `name: None` to `values`, so `signup()` overrides the copied template user's name and required-name validation rejects account creation; the caller sees a signup error.

Add `name` to `values` only when the POST supplies it.

Also at `auth_signup_verify_email/controllers/main.py:56`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 3 findings to address first, and if the new guards or field allowlist are wrong, the signup route could reject legitimate users or create accounts with unintended values; an account or activation email already created cannot be undone by reverting, though the exposure is bounded to affected signups.

Blocking findings: auth_signup_verify_email/controllers/main.py:56, auth_signup_verify_email/controllers/main.py:30, auth_signup_verify_email/controllers/main.py:55


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

values = {
"login": login,
"name": request.params.get("name"),
"email": request.params.get("email") or login,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Unverified login addresses can be claimed

When an unauthenticated caller submits a valid, unclaimed victim address as login and an attacker-controlled address as email while public signup is enabled, passwordless_signup validates login but stores the caller-supplied email; reset_password(login) then sends the activation link to that stored address. An attacker can register an unclaimed victim address as the login while receiving its activation link, enabling identity squatting and impersonation.

Set the signup email to the validated login, or validate that any separately accepted email is the same address whose ownership must be verified.

Prompt for AI agents
In `auth_signup_verify_email/controllers/main.py` at line 56:

**Unverified login addresses can be claimed**

When an unauthenticated caller submits a valid, unclaimed victim address as `login` and an attacker-controlled address as `email` while public signup is enabled, `passwordless_signup` validates `login` but stores the caller-supplied `email`; `reset_password(login)` then sends the activation link to that stored address. An attacker can register an unclaimed victim address as the login while receiving its activation link, enabling identity squatting and impersonation.

Set the signup email to the validated login, or validate that any separately accepted email is the same address whose ownership must be verified.

Comment on lines +27 to +30
if not qcontext.get("token") and not qcontext.get("signup_enabled"):
raise NotFound()
if qcontext.get("error"):
return request.render("auth_signup.signup", qcontext)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · GET requests create accounts

When signup is enabled and a GET request includes a login parameter but no password, web_auth_signup sends any request with a login and no password to passwordless_signup, which proceeds to signup() without checking the HTTP method. A GET request can therefore create an account and send an activation email instead of only displaying the signup form.

Only run passwordless signup for POST requests; render the signup page for GET requests.

Prompt for AI agents
In `auth_signup_verify_email/controllers/main.py` at lines 27-30:

**GET requests create accounts**

When signup is enabled and a GET request includes a `login` parameter but no `password`, `web_auth_signup` sends any request with a `login` and no `password` to `passwordless_signup`, which proceeds to `signup()` without checking the HTTP method. A GET request can therefore create an account and send an activation email instead of only displaying the signup form.

Only run passwordless signup for POST requests; render the signup page for GET requests.

# params go to a sudo copy() of the template user
values = {
"login": login,
"name": request.params.get("name"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Signup rejects missing names

When a signup POST omits the name parameter, request.params.get("name") adds name: None to values, so signup() overrides the copied template user's name and required-name validation rejects account creation; the caller sees a signup error.

Add name to values only when the POST supplies it.

Also at auth_signup_verify_email/controllers/main.py:56.

Prompt for AI agents
In `auth_signup_verify_email/controllers/main.py` at line 55:

**Signup rejects missing names**

When a signup POST omits the `name` parameter, `request.params.get("name")` adds `name: None` to `values`, so `signup()` overrides the copied template user's name and required-name validation rejects account creation; the caller sees a signup error.

Add `name` to `values` only when the POST supplies it.

Also at `auth_signup_verify_email/controllers/main.py:56`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant