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

Change storage key name from email to uuid #1903

Merged
merged 11 commits into from
Jun 2, 2020

Conversation

thi4go
Copy link
Member

@thi4go thi4go commented May 6, 2020

Bug (or issue) description

The storage key name was disclosing a personal user information, the email. This diff changes the key name to be his public uuid instead of email. This is valid both for the identity key and for local storage draft records.

This diff also adds a logout modal with the option to permanently logout from the app. This will delete his identity key and his draft entries.

Depends on decred/politeia#1186
Closes #1842 and #1843

Solution description

Straightforward change on the storage key name we use to set/get a user key. A workaround had to be done for a freshly registered user. Regarding this:

Problem: we need the user key to make the /register (cms) and /user/new (pi) calls on the backend. Also for verifying his email. At this stage, the frontend does not have the user's uuid to set the appropriate storage key name.

Solution: use the username as storage key name temporarily, until the user makes his first login on the app. When he does, we check if there's any local key saved under his username, and if so, we change it to be his uuid. This requires a minor change in the backend (PR decred/politeia#1186) so that a user's username is included in the verify email URL. This way we can retrieve his signing key before making the request.

Copy link
Member

@tiagoalvesdulce tiagoalvesdulce left a comment

Choose a reason for hiding this comment

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

Code looks good. @degeri do you like the approach?

@degeri
Copy link
Member

degeri commented May 8, 2020

this does not break password reset ? Does it need to be UUID ? why cant it be a random string ?

@thi4go
Copy link
Member Author

thi4go commented May 8, 2020

It does not break password reset, mate @degeri. We discussed this and figured uuid would be enough, since it is already a public data. We also need a way to associate the random string to the user, so that he can retrieve his key from the storage properly. This means that even if it were a random string, it would need to be associated with some user data on the storage, which would defeat the initial purpose of it. Bringing this problem up to the backend is not ideal imo, since we would'nt gain much from it being a random string.

@degeri
Copy link
Member

degeri commented May 8, 2020

just reiterating matrix chat here. We have decided to replace email with username to store the keyvalue during the initial setup (before first login) . After that it will be replaced with UUID.

@thi4go thi4go marked this pull request as draft May 9, 2020 14:37
@thi4go thi4go marked this pull request as ready for review May 11, 2020 20:40
Copy link
Member

@victorgcramos victorgcramos left a comment

Choose a reason for hiding this comment

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

Hey @thi4go, this PR looks pretty good. I have only one concern regarding the "Permanent Logout" feature that was added by this diff. From what I can see, the local storage keeps storing the session keys (I guess it's due to the usage of the removeItem from localforage's API. Check my inline comment).

local storage example

I would expect that both keys and values get removed and completely erased from Local Storage.

@degeri @tiagoalvesdulce @amassarwi what do you think?

src/lib/pki.js Show resolved Hide resolved
@thi4go
Copy link
Member Author

thi4go commented May 20, 2020

@victorgcramos good catch mate. This was actually involving the way we used to clear the localStorage, and not localforage. Anyhow, I pushed the fix for this 👍

Copy link
Member

@victorgcramos victorgcramos left a comment

Choose a reason for hiding this comment

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

LGTM!

@degeri
Copy link
Member

degeri commented May 21, 2020

This removes all the users keys or only the logged in user ?

@thi4go
Copy link
Member Author

thi4go commented May 21, 2020

Only the logged in user @degeri. Thought it would be best, since deleting all user data would involve others identities and drafts that might not be backed up yet. Not sure that would be fair. What do you think?

@victorgcramos
Copy link
Member

@thi4go I agree with your thoughts, makes sense.

@degeri
Copy link
Member

degeri commented May 22, 2020

Sounds fine I am good with it.

@tiagoalvesdulce
Copy link
Member

@thi4go can you rebase?

@tiagoalvesdulce tiagoalvesdulce merged commit 47d51fa into decred:master Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logout permanently
4 participants