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

Improve email verification #3681

Merged
merged 3 commits into from
May 11, 2017
Merged

Improve email verification #3681

merged 3 commits into from
May 11, 2017

Conversation

aontas
Copy link
Contributor

@aontas aontas commented Mar 31, 2017

This should fix the issues as outlined in #3393 and #3432

@facebook-github-bot
Copy link

@aontas updated the pull request - view changes

Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

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

this looks good to me and is a nice catch. Would like @flovilmart to take a look at too.

@acinader acinader requested a review from flovilmart April 5, 2017 20:17
@flovilmart
Copy link
Contributor

@acinader that's a hot fix, but we need something for those protected fields, declared at the class level. Also we strip authData and password from the responses, I believe this should be stripped at the same spot no?

@aontas
Copy link
Contributor Author

aontas commented Apr 12, 2017

@flovilmart So you would prefer the logic I added in UsersRouter to instead live in the cleanResultOfSensitiveUserInfo function in RestQuery.js?

And move the other logic (disallowing emailVerified update) to the UserController?

When I put these changes in, would that be enough to satisfy your comments? If not can you provide some more direction as to what you would consider appropriate?

@flovilmart
Copy link
Contributor

@aontas I believe we should keep it in the responses, unless that causes an issue... (http://docs.parseplatform.org/rest/guide/#verifying-emails), only for the current user.

perhaps we should validate that the update don't contain the emailVerified here: https://github.com/parse-community/parse-server/blob/master/src/RestWrite.js#L346

@aontas
Copy link
Contributor Author

aontas commented Apr 13, 2017

@flovilmart There is nothing in this PR that removes the emailVerified flag from the responses. I agree that it is required to stay there. The only things that are removed are internal data members, which have been denoted by a leading underscore (ie, "_email_verify_token" which is the secret provided via email).

I will move the logic to check the incoming emailVerified data in RestWrite.

@codecov
Copy link

codecov bot commented Apr 13, 2017

Codecov Report

Merging #3681 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3681      +/-   ##
=========================================
+ Coverage   90.22%   90.3%   +0.07%     
=========================================
  Files         114     114              
  Lines        7491    7498       +7     
=========================================
+ Hits         6759    6771      +12     
+ Misses        732     727       -5
Impacted Files Coverage Δ
src/Routers/UsersRouter.js 88.88% <100%> (+1.86%) ⬆️
src/RestWrite.js 94.54% <100%> (+0.23%) ⬆️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 95.44% <0%> (+0.13%) ⬆️
src/Controllers/SchemaController.js 97.29% <0%> (+0.24%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4fbe354...c50b34a. Read the comment docs.

Copy link
Contributor

@flovilmart flovilmart left a comment

Choose a reason for hiding this comment

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

One small fix, otherwise we'll miss out some test :)

@@ -26,7 +26,7 @@ function verifyACL(user) {
expect(perms['*'].write).not.toBe(true);
}

describe('Parse.User testing', () => {
fdescribe('Parse.User testing', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops

@aontas
Copy link
Contributor Author

aontas commented Apr 13, 2017

Oops. Yeah. Fixed now.

Copy link
Contributor

@flovilmart flovilmart left a comment

Choose a reason for hiding this comment

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

@aontas still a few pending questions here and there. Thanks for the work you're putting onto it!

verifyUserEmails: true,
emailAdapter: emailAdapter,
publicServerURL: "http://localhost:8378/1"
})
Copy link
Contributor

Choose a reason for hiding this comment

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

reconfigureServer returns a promise, can you handle that please?

const user = new Parse.User();
 user.set({
  username: 'hello',
  password: 'world'
});

reconfigureServer({
  appName: 'unused',
  verifyUserEmails: true,
  emailAdapter: emailAdapter,
  publicServerURL: "http://localhost:8378/1"
 }).then(() => {
  return user.signUp()
})
... 

sendMail: () => Promise.resolve()
}

reconfigureServer({
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

@@ -57,6 +57,17 @@ export class UsersRouter extends ClassesRouter {
const user = response.results[0].user;
// Send token back on the login, because SDKs expect that.
user.sessionToken = sessionToken;

// Remove hidden properties.
for (var key in user) {
Copy link
Contributor

Choose a reason for hiding this comment

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

just a quick question,
Those fields get stripped only when calling /me, but not when let's say we make an unauthenticated query?

Could we add a test for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What sort of unauthenticated query would we want these fields to be available?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the point, we won't. But those fields would only be stripped here, not everywhere we need them to be stripped

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There does seem to be handling somewhere that removes hidden fields (see updated test where users/ is retrieved without hidden field).

The general case where all hidden fields are removed from all unauthenticated queries is likely better to be talked in its own issue, rather than tacked on to this PR.

Does this current version require any further changes?

@aontas
Copy link
Contributor Author

aontas commented Apr 23, 2017 via email

@aontas
Copy link
Contributor Author

aontas commented May 1, 2017

PR #3768 seems to have caused this build to fail. It was merged even though the build failed: https://travis-ci.org/parse-community/parse-server/builds/227340428

@flovilmart
Copy link
Contributor

Let's merge that one for the upcoming release, Thanks @aontas !

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.

None yet

4 participants