Data model refactor #973
Data model refactor #973
Comments
|
I'm finally looking at this... |
|
I think this looks great relationally. The I think we should change I'm sure we'll need to adjust it as we go, but I like this a lot |
Does this mean that I could try hitting the API with an email address of someone I know and gaining knowledge of another email address they might use? e.g. if I tried your Mozilla address but you'd signed up with your personal one (and added your Mozilla address later). |
This is a very good point. We could mitigate this by only allowing login with the primary email, and trying really hard to update |
|
Taking this bug back, next step is for me to break it down into smaller implementation tasks. |
Depending on how we implement it I think the email change flow will cause |
|
To be explicit: we still only plan to allow login with your "primary" email address. So you couldn't use a non-primary email to hit this API and discover the primary one, but there might be a brief window wherein you can hit it with the new primary email and discovery what the old one was. |
|
@dannycoates says he can proceed with the federated-login stuff without us having to land any parts of this refactor, so I'm putting it back in the backlog for a little while. It will come up again as we move on device-management user stories. |
Specifically, I can easily land "phase 1" of federated-login now. Later stages, whoops flow, key options, and others will be made vastly easier with a refactor :) |
|
ref #721 which describes some additional API changes we can make to reflect the status of an email. |
|
We're doing parts of this with the "add recovery email" feature, so I don't think we need to keep this old issue open. We can still refer back to it if need be. |
We've got a fair backlog of refactorings that we'd like to apply to the core account data model. In service of #957, let's bite the bullet and rejigger things. Below is what @dannycoates, @philbooth and I came up with the other day.
The current data model has all the account data in one big table like this:
Key ideas for refactoring:
So we'll wind up with a much slimmer accounts table:
An "email" table that breaks out each address as its own thing, keyed by normalized address and mapping to a particular uid:
The "emailState" field here would allow us to represent states other than "unverified" and "verified", such as "bounced". This will probably evolve as we add more features in the multi-email case, like managing communication preferences.
Obviously we need to be able to look up the email addresses associated with a particular account:
We also create a separate "passwordAuth" table for the login-related data:
Of note here, we're explicitly storing the "authEmail" that should be used for salting the authPW calculation, but you can't use it to look up the row. This table is indexed by uid and the authEmail may not match the primary email on the account. To do a login based on email/password we'd need to:
Also note that everything related to the password goes in this table, including
wrap(wrap(kB)). Users without a password do not have a kB.For a future federated-login world, we'd have a "federatedAuth" table to track what accounts came from what identity providers. The details of such a table are out of scope for this refactor.
@dannycoates @philbooth f?
How did I do capturing the discussion from the other day? Anything to add?
This is all fine and well from a schema-design point of view, but I suspect we might hit a few bumps when we get around to implementing it. For example, many of our queries rely on being able to slurp in a bunch of account data when you look up a sessionToken. But I suspect the only way to find the rough edges here will be to try it out.
If the above captures most of what we wanted in the refactor, I'll go ahead and try to break it down into smaller incremental tasks.
The text was updated successfully, but these errors were encountered: