Skip to content

require a verified email address for any account action #15692

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

Merged
merged 23 commits into from
Apr 1, 2024
Merged
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: 1 addition & 1 deletion tests/functional/manage/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_save_account(self, pyramid_services, user_service, db_request):
db_request.path = "/manage/accounts/"
db_request.POST = MultiDict({"name": "new name", "public_email": ""})

views.ManageAccountViews(db_request).save_account()
views.ManageVerifiedAccountViews(db_request).save_account()
user = user_service.get_user(user.id)

assert user.name == "new name"
Expand Down
160 changes: 102 additions & 58 deletions tests/unit/manage/test_views.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tests/unit/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ def add_policy(name, filename):
"/account/verify-project-role/",
domain=warehouse,
),
pretend.call(
"manage.unverified-account", "/manage/unverified-account/", domain=warehouse
),
pretend.call("manage.account", "/manage/account/", domain=warehouse),
pretend.call(
"manage.account.publishing", "/manage/account/publishing/", domain=warehouse
Expand Down
6 changes: 4 additions & 2 deletions warehouse/accounts/security_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def _permits_for_user_policy(acl, request, context, permission):
if (
isinstance(res, Allowed)
and not request.identity.has_primary_verified_email
and request.matched_route.name.startswith("manage")
and request.matched_route.name != "manage.account"
and request.matched_route.name
not in {"manage.unverified-account", "accounts.verify-email"}
):
return WarehouseDenied("unverified", reason="unverified_email")

Expand Down Expand Up @@ -214,6 +214,8 @@ def _check_for_mfa(request, context) -> WarehouseDenied | None:
"manage.account.totp-provision",
"manage.account.two-factor",
"manage.account.webauthn-provision",
"manage.unverified-account",
"accounts.verify-email",
]

if (
Expand Down
Loading