Repository navigation
[20.0][IMP] auth_signup_verify_email: review suggestions for OCA/server-auth#1064 #2
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
base: 20.0-mig-auth_signup_verify_email
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import logging | ||
|
|
||
| from email_validator import EmailSyntaxError, EmailUndeliverableError, validate_email | ||
| from werkzeug.exceptions import NotFound | ||
|
|
||
| from odoo.http import request, route | ||
|
|
||
|
|
@@ -20,12 +21,19 @@ def web_auth_signup(self, *args, **kw): | |
| return super().web_auth_signup(*args, **kw) | ||
|
|
||
| def passwordless_signup(self): | ||
| values = request.params | ||
| 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", "") | ||
|
|
||
| # Check good format of e-mail | ||
| try: | ||
| validate_email(values.get("login", "")) | ||
| validate_email(login) | ||
| except EmailSyntaxError as error: | ||
| qcontext["error"] = getattr( | ||
| error, | ||
|
|
@@ -39,29 +47,25 @@ def passwordless_signup(self): | |
| except Exception as error: # noqa: BLE001 | ||
| qcontext["error"] = str(error) | ||
| return request.render("auth_signup.signup", qcontext) | ||
| if not values.get("email"): | ||
| values["email"] = values.get("login") | ||
|
|
||
| # remove values that could raise "Invalid field '*' on model 'res.users'" | ||
| values.pop("redirect", "") | ||
| values.pop("token", "") | ||
|
|
||
| # Remove password | ||
| values["password"] = "" | ||
| # Only pass the fields the signup form is meant to set: request | ||
| # params go to a sudo copy() of the template user | ||
| values = { | ||
| "login": login, | ||
| "name": request.params.get("name"), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Signup rejects missing names When a signup POST omits the Add Also at Prompt for AI agentsIn `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`. |
||
| "email": request.params.get("email") or login, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 agentsIn `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. |
||
| "password": "", | ||
| } | ||
| sudo_users = request.env["res.users"].with_context(create_user=True).sudo() | ||
|
|
||
| try: | ||
| with request.env.cr.savepoint(): | ||
| sudo_users.signup(values, qcontext.get("token")) | ||
| sudo_users.reset_password(values.get("login")) | ||
| sudo_users.reset_password(login) | ||
| except Exception: | ||
| # Duplicate key or wrong SMTP settings, probably | ||
| _logger.exception("Passwordless signup failed") | ||
| if ( | ||
| request.env["res.users"] | ||
| .sudo() | ||
| .search([("login", "=", qcontext.get("login"))]) | ||
| ): | ||
| if request.env["res.users"].sudo().search([("login", "=", login)]): | ||
| qcontext["error"] = self.env._( | ||
| "Another user is already registered using this email address." | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
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
loginparameter but nopassword,web_auth_signupsends any request with aloginand nopasswordtopasswordless_signup, which proceeds tosignup()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