-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Refactor ValidateLogin #11457
Refactor ValidateLogin #11457
Conversation
Hey! So the code looks great, and I got both this flow and the bank account thing to work great on desktop/web and android/chrome. However, scenario |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm so for the first case, what I think I'm supposed to test is:
- Log in to NewDot & OldDot with the same account
- In OldDot, add a secondary login (like [email protected])
- Use
script/clitools.sh generator:validateLink
to create a validation URL, take just the validation code - Open
http://localhost:8080/v/<accountID>/<validationCode>
and see that the page now shows the last report you were on (this works) - Go back to OldDot, you should see that the secondary login is now validated
I'm not seeing step 5 happen - is that a problem? I don't see that the secondary login is now validated 🤔 Even after rebuilding Auth & retesting I still don't see this happening, am I doing something wrong or am I reading the test steps incorrectly?
Oops @Beamanator I hadn't checked that part either - I'm also not seeing the validation go through on OldDot. It seems like that's unrelated to this code, but good to confirm (I wonder if using clitools it's validating as a separate account, rather than a secondary login?) |
Oh good catch related to the Could you test with the link code sent to your email? I'm going to update the instructions to do it in that way since QA will be able to only test it with the email link. |
Yup, it works only by copying the validation code from the validation link from the email. I recorded a test with iOS/Safari validating a secondary login (the tricky part was "copy-pasta" of the validation code because I couldn't paste it into the iOS simulator 😄). Screen.Recording.2022-10-05.at.15.56.35.mov |
Noice noice I'll try it with emailed links (not sure why that would be different though, maybe there's some weird bug in the generator script?) Also there's conflicts 😅 sorry |
Ugg still not working for me with email links 🙃 Can you try, @dangrous ? I wonder if I'm holding something wrong, like in PHP or Auth? Very confused :( |
All 4 tests cases DO work for me (at least on desktop) when I actually have the emails sent (expected behavior on the NewDot side, and the email addresses are marked as verified on OldDot. I'm going to try mobile web ios/android again and if that works I'll go ahead and checklist/merge [EDIT: once conflicts are resolved]. If not, we should discuss how to move ahead if we can't fully test... |
Okay, confirmed! This works on all web platforms! |
Hey @dangrous! Thanks for testing, before you test on mobile again, I noticed the change that introduced the conflict changed the flow slightly. Since And since we can't add secondary logins in NewDot atm (afaik that's part of the Account Settings project, @Beamanator correct me if I'm wrong), I think it's OK to navigate always to home instead of the previous report for this refactor cc @marcaaron @tgolen I'm going to update the test steps and test again on mobile in a bit. |
Updated video for web desktop, also tested on mobile web (Chrome and Safari) and worked fine 👍🏽 Screen.Recording.2022-10-06.at.13.45.43.mov |
Yeah I think that nav update makes sense, the existing path was kind of annoying in my case because the last opened report was a chat with a user i deleted so it would just never load haha. Not an issue for someone who would be using the app frequently, but home seems like the best destination. Will test through now! |
Okay tested again and everything works as expected on ios safari, android chrome, and desktop chrome. HOWEVER I happened to try being logged into a different account on NewDot, and the same flow happens. Meaning - if I'm logged into an account that isn't the account being validated, I will just be auto returned to where I was in the app AND the secondary login for the other account will still be validated in OldDot. This seems... bad, right? I don't think it's related to this particular PR, so I think we can still merge this, but we should probably make a separate issue. Thoughts? |
Ugg I'm glad it's working for both of y'all, maybe there's something wrong with my env 🙃
Ooh thanks for testing this @dangrous ! I thinkkk yes that's bad... I'm not exactly sure how this could be used maliciously but still it doesn't seem good.
Hmm true it's not related to this PR, buttt it's probably related to the Web-E version of this PR (the one where ValidateLogin was added in the backend) so I would vote we hold this on fixing that in Web-E - since this PR isn't "critical" (it's not "fixing" anything, I think) - it's just refactoring stuff, and possibly helping introduce the bug you caught Note: If that bug already exists on production we can probably go ahead and merge this one, but I am guessing it doesn't? Wanna try? |
It actually does exist on production - just tried it. I mean, I can't really think of a way that it could be used for evil? But seems insecure nonetheless. Like I guess if you typed in the wrong email and someone else happened to verify it then they would have access to your account, but I think it could only be an accident not intentional. |
Yeah I think this scenario can only happens if the malicious person has access to the validation email, but in that case I think we can do nothing because by design the account can be validated with or without the authtoken (whether a user is logged in or not in NewDot). |
I'm gonna go ahead and checklist, and @Beamanator you can have the final word! I think we can go ahead and merge this since the (potential) flaw exists on production anyway. PR Reviewer ChecklistThe reviewer will copy/paste it into a new comment and complete it after the author checklist is completed
|
@Beamanator it'd be awesome to make sure you put this PR on your list for Monday! We technically already closed our this refactor, so I like to re-close it out and focus on the few remaining APIs as soon as we can. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for testing in production @dangrous and I agree with y'all's assessment that this weird flow reeeeally can't be taken advantage of. Code looks good so let's !
@Beamanator looks like this was merged without passing tests. Please add a note explaining why this was done and remove the |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Tests were passing Melvin 🙃 |
Do we want to still create an issue to require an authToken for that validation action? or are we confident it doesn't need one? My opinion would be to update it because better safe than sorry, but I'm open! |
Good call @dangrous - If it were me, I'd bring this discussion to #engineering-chat b/c maaybe this is a known thing & is very difficult to work around, or maybe it's "fine" & expected ORR maybe nobody has tested this flow and it's actually something we should fix! Do you mind bringing the convo there to see what others think? |
🚀 Deployed to staging by @Beamanator in version: 1.2.13-0 🚀
|
Tested, works well! ✅ |
🚀 Deployed to production by @yuwenmemon in version: 1.2.13-5 🚀
|
…Refactor Refactor ValidateLogin
cc @Beamanator since you noticed the original refactor was reverted 😄
Details
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/218822
Tests
(steps taken from #10026)
Four use cases can occur with this flow:
Resulting Conditions
In the first two cases, the user is simply redirected to
their last open report/conversationhome with no error message displayed. Additionally, in Case 1, the account is silently validated behind the scenes.In the latter two cases, the user is redirected to the login page. In Case 4, an error message would displayed below the password field stating: "This set password link is invalid or has expired...", while in Case 3, the user would encounter a password prompt.
To test the cases described above:
Verify secondary email for Expensify
and copy the link address ofclick on this link to validate your login
(we just want the last part of the URL, i.e./v/16/WSSWMNNMH
)http://localhost:8080/v/<accountID>/<validationCode>
on local devhttp://staging.new.expensify.com/v/<accountID>/<validationCode>
on staginghttp://staging.new.expensify.com/v/<accountID>/<validationCode>
on productionAdditionally, test the steps for this regression that reverted the original PR.
Connect bank account
Connect bank account
modal and open it again (it should show the page with the titleAlmost done!
)Screen.Recording.2022-10-04.at.17.36.31.mov
PR Review Checklist
PR Author Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)PR Reviewer Checklist
The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
have been tested & I retested again)/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)QA Steps
Follow same steps from
Test
section.Screenshots
Web
User is logged into NewDot:
Screen.Recording.2022-10-04.at.17.15.05.mov
User is NOT logged into NewDot, and their secondary login is NOT validated:
Screen.Recording.2022-10-04.at.17.20.19.mov
User is NOT logged into NewDot, and their secondary login is already validated and/or the link is invalid:
Screen.Recording.2022-10-04.at.17.21.16.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
Not applicable, validation link opens browser
iOS
Not applicable, validation link opens browser
Android
Not applicable, validation link opens browser