-
Notifications
You must be signed in to change notification settings - Fork 464
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
Prevent multiple user accounts with the same account id #725
Comments
What if we could use the |
I’m not sure what you mean, could you explain it in a bit more detail? |
We can update body: internals.serialise('account', options, cache.id) to body: internals.serialise('account', options, generateId()) in signup.js
From what I understand What do you think about this @gr2m ? |
I fear that won’t work, the account ID we pass to the sign up must be the same that we have stored locally, as we will add it to all documents created & updated in the We might do something else on the client side. We could keep track that a signup was already done successfully for the current account id and either prevent another signup or send a different request that would rename the document of the previous signup. But either way, we cannot trust the client, people could send their own requests without even using the client, so we have to secure this on the server side anyway, by preventing that two account documents with the same account id can be created. |
Won't you be able to create and add documents only when you have authorized the user?
This should be an obvious validation on the server-side no doubt. |
No :) account ids cannot be changed |
I think the we can solve this problem and at the same time prepare to properly implement custom user confirmation workflows. What happens todayIn the browser, I create an account with hoodie.account.signUp({username: 'test', password: 'test'}) Which sends a accounts.add({
username: username,
password: password,
createdAt: createdAt || currentTime,
signedUpAt: currentTime,
include: query.include,
id: id
}) which creates a document in Hoodie’s users database which looks like {
"type": "user",
"name": "test",
"createdAt": "2017-07-30T03:24:45.700Z", // when account was created locally
"signedUpAt": "2017-07-30T03:53:00.335Z", // when signed up on the server
"roles": ["id:ow7eior"],
"iterations": 10,
"password_scheme": "pbkdf2",
"salt": "1a71231d513017012313417913b1db1151fd1121fe1241fb",
"derived_key": "a99ee677d8a59fdc4a00215b1eac68ce27428d53",
"_id": "org.couchdb.user:test",
"_rev": "1-6a23e40ab47bef398205241333889f18"
} We don’t have any confirmation flow implemented at this point, once created, a user can sign in to the account. Because of that, the same user can create as many user accounts as they want, and they will all have the same SuggestionWhen creating a user account, we store a new property
Because the I would remove the existing Process of implementation
To be discussed
Anything else? |
Today I can do this:
This creates two accounts with the same account id. That is a problem because
GET /_users/_design/byId/_view/byId?key="<ID HERE>"
will now return two results, but only the first one is used. If I sign in two the second account, my session will not be valid when using thebyId
view to find the account doc to validate it against.We must prevent multiple account docs to be created that have the same account id. I don’t know what the best strategy for that could be. We might want to change how we store accounts entirely and instead of making the username part of the
doc._id
, we use the id instead, as the username can change while the account id cannot. We’ll have to guarantee both to be unique anyway.ping @janl can you think of a good strategy to guarantee uniqueness of a CouchDB doc property value in a database?
The text was updated successfully, but these errors were encountered: