Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Limit pending email verifications #4571

Closed
wants to merge 20 commits into from

Conversation

chadwhitacre
Copy link
Contributor

@chadwhitacre chadwhitacre commented Aug 14, 2017

← Persist email verifications (#4573) — Support queuing emails without participants (#4548) →


Fixes #4557.

Todo

  • Test/think through having more than one unverified email (two cases: merge/take-over, and pre-existing conditions)
  • Review envvars

@@ -106,6 +103,16 @@ def validate_email_verification_request(self, c, email, *packages):
if not all(email in p.emails for p in packages):
raise EmailNotOnFile()

unverified_email = c.one("""
SELECT address
Copy link
Contributor

Choose a reason for hiding this comment

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

A user could repeatedly add an email + remove it to circumvent this restriction, no? The throttling strategy we use will have to rely on previous state (as you've mentioned in the ticket description)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to start also thinking about not deleting email addresses, because when we start handling bounces and complaints (#4284) we'll want to retain that info for a given email address even if one participant removes it and another (or the same) adds it again. Hmm ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A user could repeatedly add an email + remove it to circumvent this restriction, no?

Eureka! Turns out it makes the most UX sense to disallow removing emails when verification is pending, to properly communicate the reality that the pending verification still exists. But, if we truly disallow removing emails when verification is pending, then we'll have closed the repeatedly-add-and-remove loophole. Violà!

Proceeding on that basis in #4579 ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Umm, what if a person mistakenly enters a wrong email address?

Copy link
Contributor

@rohitpaulk rohitpaulk Aug 23, 2017

Choose a reason for hiding this comment

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

Turns out it makes the most UX sense to disallow removing emails when verification is pending, to properly communicate the reality that the pending verification still exists.

This is also a security risk, as far as I can tell. If we don't allow canceling verification requests - a mistake in entering a user's email could result in a malicious user taking over their account.

Copy link
Contributor

Choose a reason for hiding this comment

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

For example, github:

screen shot 2017-08-23 at 7 49 26 pm

@chadwhitacre chadwhitacre mentioned this pull request Aug 15, 2017
1 task
@chadwhitacre
Copy link
Contributor Author

chadwhitacre commented Aug 15, 2017

Alright, after wrestling to rebase this onto #4572 I think the way to architect this is to rename email_addresses (formerly emails) to email_verifications, and then make a new email_addresses table that holds just address as primary key and a nullable verification_id.

When a participant adds an email address we file the address in email_addresses (if needed) with a null verification, and we start a new verification in email_verifications (can have multiple verifications open across users for the same address, but only one per participant per address).

When a participant completes a verification we link to it in email_addresses.verification_id. We leave any other pending verifications open in email_verifications. We never delete from email_verifications.

When a participant removes an email address we null out the verification in email_addresses. We keep the record in the table because ... because ... ?

We link to email_addresses from email_messages.

We link to email_messages from email_verifications.

@chadwhitacre
Copy link
Contributor Author

Something like that, anyway. :)

@chadwhitacre
Copy link
Contributor Author

I've kicked out #4573 to persist email verifications. Once done will revisit here to see about constraining based on past verifications.

@chadwhitacre chadwhitacre changed the title Redo throttling Limit pending email verifications Aug 16, 2017
@chadwhitacre chadwhitacre changed the base branch from master to persist-verifications August 16, 2017 09:53
EdOverflow and others added 11 commits August 16, 2017 19:43
By moving the `kw` assignment into a conditional block we ended up
depending on previous iterations of the loop to assign `kw` in the
no-doc case. Had the no-doc case been first, we would've hit a
NameError.
TestNotifyParticipants uses QueuedEmailHarness
@chadwhitacre
Copy link
Contributor Author

Working up a ttw test so we can get the user requirements here.

screen shot 2017-08-18 at 11 17 43 am

@chadwhitacre
Copy link
Contributor Author

Alright this is a mess. First of all the email listing should be styled like our other listings (homepage, search page, social profiles, etc.).

screen shot 2017-08-22 at 2 49 02 pm

@chadwhitacre
Copy link
Contributor Author

And after this PR we don't even want UI to add another email address when there is a pending verification.

@chadwhitacre
Copy link
Contributor Author

chadwhitacre commented Aug 22, 2017

But how does this interact with bulk npm claiming? We shouldn't allow interaction there either if the user has a pending verification.

@chadwhitacre
Copy link
Contributor Author

But of course we need to protect against multiple verifications in the Python/API layer and not just in the JavaScript/UI.

@chadwhitacre
Copy link
Contributor Author

chadwhitacre commented Aug 22, 2017

And what about the case where someone legitimately enters a wrong address? They shouldn't be able to remove pending verifications either (UI and API). That's bound to generate some confusion. "I entered the wrong email and now I can't remove it or submit my correct email." It'll have to be a support request with an admin intervention to undo their condition.

@mattbk
Copy link
Contributor

mattbk commented Aug 22, 2017

Are you trying to prevent people from spamming email bombing by adding secondary email addresses that point to someone else's address? Or is the verification system so monolithic that there's no way to throttle just one type of verification request?

@chadwhitacre
Copy link
Contributor Author

screen shot 2017-08-22 at 3 25 08 pm

@chadwhitacre
Copy link
Contributor Author

Are you trying to prevent people from spamming email bombing by adding secondary email addresses that point to someone else's address? Or is the verification system so monolithic that there's no way to throttle just one type of verification request?

I'm not sure how to understand these as mutually exclusive. Did our recent slack chat (archiving stuck 😞 ) clarify this?

@chadwhitacre
Copy link
Contributor Author

Closing in favor of #4579.

@chadwhitacre chadwhitacre deleted the redo-throttling branch August 23, 2017 11:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants