Skip to content
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

Rework how email verification works #3784

Merged
merged 28 commits into from
Jan 24, 2025
Merged

Rework how email verification works #3784

merged 28 commits into from
Jan 24, 2025

Conversation

sandhose
Copy link
Member

@sandhose sandhose commented Jan 9, 2025

This completely redesigns how email verification works.

Fixes #3112
Fixes #2881
Helps with #1505

This is meant to be reviewed commit by commit

As per the task list bellow, it's missing a few little things, but those are details that can be tackled later, and I'll open individual issues for them.

Tasks

Preview Give feedback

Quick screen recording on how it looks:

output.mp4

@sandhose sandhose marked this pull request as draft January 9, 2025 10:28
Copy link

cloudflare-workers-and-pages bot commented Jan 9, 2025

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8d50088
Status: ✅  Deploy successful!
Preview URL: https://1c820446.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://quenting-optional-email.matrix-authentication-service-docs.pages.dev

View logs

@sandhose sandhose force-pushed the quenting/optional-email branch 2 times, most recently from 58f4749 to 59170a3 Compare January 13, 2025 08:37
@sandhose sandhose force-pushed the quenting/design-review-jan-25 branch from e708212 to 7c57d09 Compare January 13, 2025 15:49
@sandhose sandhose force-pushed the quenting/optional-email branch from 59170a3 to 73f2840 Compare January 13, 2025 15:49
Base automatically changed from quenting/design-review-jan-25 to main January 13, 2025 15:58
@sandhose sandhose force-pushed the quenting/optional-email branch from 73f2840 to 89082a7 Compare January 14, 2025 14:35
@sandhose sandhose force-pushed the quenting/optional-email branch 2 times, most recently from bda2b00 to 5638b67 Compare January 14, 2025 15:15
@sandhose sandhose force-pushed the quenting/optional-email branch from 5638b67 to d65286d Compare January 14, 2025 15:30
@sandhose sandhose force-pushed the quenting/optional-email branch from 45d4218 to 24999ef Compare January 15, 2025 15:50
@sandhose sandhose force-pushed the quenting/optional-email branch from 24999ef to a39e1d3 Compare January 15, 2025 16:30
@sandhose sandhose marked this pull request as ready for review January 15, 2025 16:31
@sandhose sandhose requested a review from reivilibre January 15, 2025 16:31
@sandhose sandhose force-pushed the quenting/optional-email branch from a39e1d3 to ef74d47 Compare January 15, 2025 16:42
@sandhose sandhose added A-Registration-Flow Related to the user registration flow T-Enhancement New feature of request labels Jan 15, 2025
Copy link
Contributor

@reivilibre reivilibre left a comment

Choose a reason for hiding this comment

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

This is a chunky one! But in principle I'm happy with most of what's here.

I have left .s on things that looked like they'd be worth getting back to and wasn't sure if you would have done in later commits, but now I can't easily see those comments again because the diff is too big it won't load nicely :D.

I'd like to more carefully consider the security and privacy aspects of the registration flow; I've spotted some issues but am not sure there aren't others.

crates/storage-pg/src/user/email.rs Show resolved Hide resolved
crates/storage/src/queue/tasks.rs Show resolved Hide resolved
crates/tasks/src/email.rs Show resolved Hide resolved
crates/handlers/src/views/register/password.rs Outdated Show resolved Hide resolved
crates/handlers/src/views/register/steps/finish.rs Outdated Show resolved Hide resolved
crates/handlers/src/views/register/cookie.rs Show resolved Hide resolved
crates/handlers/src/views/register/cookie.rs Show resolved Hide resolved
@sandhose sandhose requested a review from reivilibre January 23, 2025 17:35
@sandhose
Copy link
Member Author

@reivilibre I think I've gone through all your comments.

I've introduced rate limiting and made it so that we disclose that the email is already in use only after verifying. I'm waiting for proper design for those screens, but what I have in the meantime is probably fine, and can be adjusted later.


// Convert to lowercase to prevent bypassing the limit by enumerating different
// case variations.
// A case-folding transformation may be more proper.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe so, but this is likely good enough. I don't think non-ASCII e-mail localparts are common at all? I have never seen one in the real-world.

To be useful, we'd have to assume the recipient server is also doing casefolding transformations. I am sceptical.

All in all, happy with just lowercasing

Copy link
Member Author

Choose a reason for hiding this comment

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

email: userEmailAuthentication.email,
})}
/>

Copy link
Contributor

@reivilibre reivilibre Jan 24, 2025

Choose a reason for hiding this comment

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

if it's not too hard to do, I'd be tempted to add a button along the lines of 'Forgot your password? Click here to recover your account' and it would be as though the user submitted the account recovery form — i.e. it would send the recovery e-mail immediately

If the user logged in with a upstream provider, maybe we could remind them which one they used, such as 'You can log in to your account using Google'

Copy link
Contributor

Choose a reason for hiding this comment

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

(if preferred, could also defer this to an issue for later)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've asked design to have a look, will iterate on that later

@sandhose sandhose merged commit 522c472 into main Jan 24, 2025
21 checks passed
@sandhose sandhose deleted the quenting/optional-email branch January 24, 2025 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Registration-Flow Related to the user registration flow T-Enhancement New feature of request
Projects
None yet
2 participants