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

[$375] [HOLD for payment 2024-08-01] [Wave Collect] [Xero] Add 2FA requirement in Authorization flow #43015

Closed
francoisl opened this issue Jun 3, 2024 · 43 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors NewFeature Something to build that is a new item.

Comments

@francoisl
Copy link
Contributor

francoisl commented Jun 3, 2024

Problem

In order to remain compliant with Xero's third-party app requirements, we need to force workspace admins to enable 2FA before they can use the connection.

Additional internal context

Solution

  • For new connections:

    • Before starting the OAuth flow, make sure the admin has 2FA enabled. If they don't, show the 2FA enablement page. After they finish setting it up, automatically resume the Xero auth flow.
    • See mockups in this comment below
  • For existing connections:

    • If a user signs in and they're admin on a workspace that is connected to Xero but don't have 2FA enabled, show them the 2FA setup steps upon signing in
    • See mockups from this comment

cc @lakchote @zanyrenney

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f129776196b2ac5f
  • Upwork Job ID: 1821257266596661328
  • Last Price Increase: 2024-08-07
@francoisl francoisl added Weekly KSv2 Internal Requires API changes or must be handled by Expensify staff NewFeature Something to build that is a new item. labels Jun 3, 2024
@francoisl francoisl self-assigned this Jun 3, 2024
Copy link

melvin-bot bot commented Jun 3, 2024

Triggered auto assignment to @sakluger (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

Copy link

melvin-bot bot commented Jun 3, 2024

⚠️ It looks like this issue is labelled as a New Feature but not tied to any GitHub Project. Keep in mind that all new features should be tied to GitHub Projects in order to properly track external CAP software time ⚠️

Copy link

melvin-bot bot commented Jun 3, 2024

Triggered auto assignment to Design team member for new feature review - @dannymcclain (NewFeature)

@francoisl
Copy link
Contributor Author

I'll add a few mockups when I have edit access to Figma again.

@dannymcclain
Copy link
Contributor

@francoisl let me know if you need me to mock anything up or take care of anything in Figma! 🤝

@francoisl
Copy link
Contributor Author

Thanks. I got an email from Figma saying that Jon gave me edit access but I still can't seem to edit anything.

Basically I was trying to edit the Initial Setup part of the Xero mockups and add the 2FA flow in between. I was thinking of making two variations:

  • one where we show the Two-factor authentication flow directly after you click Set up
  • one with an intermediary modal with additional context, with text like "To connect to Xero, please enable Two-factor authentication first [Continue]"

@dannymcclain
Copy link
Contributor

Super weird. I see that you were upgraded yesterday, but when I went into the file it still said you were requesting access (I gave it to you). I wonder if that file just hadn't been refreshed or something since Jon upgraded you. Anyways, try it again if you want, or I'm happy to do some jammin'.

@dannymcclain
Copy link
Contributor

Added a little flow here in Figma.

I think it's better to tell people "Hey you need to enable 2fa to use xero" so I like including the intermediary modal.

image

@francoisl
Copy link
Contributor Author

francoisl commented Jun 10, 2024

That's great, thanks Danny!

Looks like I was wrong about the sign-in flow and <ValidateLoginPage> doesn't do what I expected, so we'll also need to make some changes to make people enable 2FA when they sign in. I'm thinking we add an extra step after entering the magic code. Here's a rough draft - Figma here:

image

I changed the text description, but we can also make it more generic to accommodate the case when people sign in and they need to enable 2FA because they're on a domain group with that requirement.

@dannymcclain
Copy link
Contributor

Ah I see, yeah that makes sense to me!

@muttmuure
Copy link
Contributor

Looks great to me

@melvin-bot melvin-bot bot added the Overdue label Jun 19, 2024
@dannymcclain
Copy link
Contributor

Any updates here?

@melvin-bot melvin-bot bot removed the Overdue label Jun 19, 2024
@rushatgabhane
Copy link
Member

yo yo yo sorry i lost track of this issue. can you please assign it to me?

@rushatgabhane
Copy link
Member

rushatgabhane commented Jun 20, 2024

PR raised #44059

@rushatgabhane
Copy link
Member

rushatgabhane commented Jun 20, 2024

@francoisl everything tests well but we might have some hiccups on how 2FA works.

For the flow: admin signs in and has a policy connected to Xero.

  1. Login
  2. Start 2FA steps
  3. Scan QR code in authenticator
  4. Paste the 6 digit code

Expected: the app becomes usable again.
Actual: the API call to enable 2FA completes but the 2FA loader spins infinitely. The app is unusable until we do a re-login.

Screen.Recording.2024-06-20.at.08.mp4

@francoisl
Copy link
Contributor Author

Hm weird. I'll look into this today.

@francoisl
Copy link
Contributor Author

As far as I can tell, it's because the authToken returned by TwoFactorAuth_Validate is not merged into Onyx before the next API call to ReconnectApp.

In short, when 2FA is required to be enabled on sign-in like in our case here, the backend will first send an authToken that has very limited permissions - one of the very few API commands it can execute is TwoFactorAuth_Validate. That API command then returns a "regular" authToken that can execute other API commands.

As an example here, after signing in let's say I get this authToken 0322AAEA4169... - this is a two-factor setup authToken with limited permissions.

image

Once I enter an OTP code to enable 2FA, the client calls TwoFactorAuth_Validate, which returns a new authToken, in this case E6CE5CDF6621...

image

However, immediately after we see that there is an API call to ReconnectApp, but for some reason it's still using the limited authToken 0322AAEA4169...

image

This is why the backend returns an error "Two Factor Authentication Required" and the app doesn't load.

I think the reason we call ReconnectApp before updating the authToken in Onyx is because of that OnyxUpdates.saveUpdateInformation() call here, though I can't think of how to fix the issue. I tried adding WRITE_COMMANDS.TWO_FACTOR_AUTH_VALIDATE to const requestsToIgnoreLastUpdateID but that doesn't fully solve the issue because then we don't call ReconnectApp at all.

@melvin-bot melvin-bot bot removed the Overdue label Jul 24, 2024
@c3024
Copy link
Contributor

c3024 commented Jul 25, 2024

@sakluger

  1. I reviewed the PR 😆

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jul 25, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-07-25] [Wave Collect] [Xero] Add 2FA requirement in Authorization flow [HOLD for payment 2024-08-01] [HOLD for payment 2024-07-25] [Wave Collect] [Xero] Add 2FA requirement in Authorization flow Jul 25, 2024
Copy link

melvin-bot bot commented Jul 25, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.11-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-08-01. 🎊

For reference, here are some details about the assignees on this issue:

  • @rushatgabhane requires payment through NewDot Manual Requests
  • @c3024 requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Jul 25, 2024

BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@rushatgabhane / @c3024] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@sakluger] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.

@rushatgabhane
Copy link
Member

@sakluger i think 500 would be great because it was hard to nail down the nitty gritty of this task.

@rushatgabhane
Copy link
Member

@c3024 could you please add regression test steps

@c3024
Copy link
Contributor

c3024 commented Jul 30, 2024

Regression test proposal

Test 1:

Pre-requisite:

Have an account A that
1. does not have 2FA.
2. is an admin of a control policy P

Steps:

  1. Login with the above specified account A
  2. Click on Workspaces > Click on the control policy P specified in the pre-requisite > Click on Accounting in the left hand panel
  3. Click on Connect Xero
  4. Verify that 2FA modal is shown
  5. Complete the 2FA setup flow
  6. Verify that the Xero integration page opens now

Test 2:

Pre-requisites:

Have an account A that
1. does not have 2FA
2. has a Xero accounting configured policy
3. is an admin of this policy

Steps:

  1. Login with the above specified account A
  2. Verify that 2FA modal is shown with loading indicator behind
  3. Click on Enable Two Factor Authentication button on the modal
  4. Verify that the Avatar and Name in the left hand panel of Settings page has loading indicator
  5. Click on Two Factor Authentication in the center panel and complete the 2FA setup flow
  6. Verify that now the Avatar and Image in the left hand panel of Settings page is fully loaded with details
  7. Click on Inbox
  8. Verify that LHN and Center Pane load fully

Copy link

melvin-bot bot commented Aug 1, 2024

Payment Summary

Upwork Job

BugZero Checklist (@sakluger)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@melvin-bot melvin-bot bot added the Overdue label Aug 2, 2024
@JmillsExpensify
Copy link

Can I get a payment summary on this issue?

@sakluger sakluger added Daily KSv2 and removed Weekly KSv2 labels Aug 7, 2024
@melvin-bot melvin-bot bot removed the Overdue label Aug 7, 2024
@sakluger
Copy link
Contributor

sakluger commented Aug 7, 2024

Sorry about that! I missed it because it wasn't automatically moved to Daily.

I chatted with @francoisl via DM to figure out what was going on here. We won't penalize for regressions here because the app was already unusable if you were an admin on a Xero workspace prior to the first PR.

Regarding price, we both thought that $500 was a bit high, but given the trickiness, we'll pay $375 - a bit more than the standard $250.

@sakluger sakluger added External Added to denote the issue can be worked on by a contributor and removed Internal Requires API changes or must be handled by Expensify staff labels Aug 7, 2024
Copy link

melvin-bot bot commented Aug 7, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01f129776196b2ac5f

@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-08-01] [HOLD for payment 2024-07-25] [Wave Collect] [Xero] Add 2FA requirement in Authorization flow [$250] [HOLD for payment 2024-08-01] [HOLD for payment 2024-07-25] [Wave Collect] [Xero] Add 2FA requirement in Authorization flow Aug 7, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 7, 2024
Copy link

melvin-bot bot commented Aug 7, 2024

Current assignees @rushatgabhane and @c3024 are eligible for the External assigner, not assigning anyone new.

@sakluger sakluger changed the title [$250] [HOLD for payment 2024-08-01] [HOLD for payment 2024-07-25] [Wave Collect] [Xero] Add 2FA requirement in Authorization flow [$375] [HOLD for payment 2024-08-01] [HOLD for payment 2024-07-25] [Wave Collect] [Xero] Add 2FA requirement in Authorization flow Aug 7, 2024
Copy link

melvin-bot bot commented Aug 7, 2024

Upwork job price has been updated to $375

@sakluger sakluger changed the title [$375] [HOLD for payment 2024-08-01] [HOLD for payment 2024-07-25] [Wave Collect] [Xero] Add 2FA requirement in Authorization flow [$375] [HOLD for payment 2024-08-01] [Wave Collect] [Xero] Add 2FA requirement in Authorization flow Aug 7, 2024
@sakluger
Copy link
Contributor

sakluger commented Aug 7, 2024

@JmillsExpensify the payment summary is ready: #43015 (comment)

@JmillsExpensify
Copy link

$375 approved for @rushatgabhane

@sakluger
Copy link
Contributor

sakluger commented Aug 9, 2024

I completed the payment to @c3024 via Upwork.

@sakluger sakluger closed this as completed Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors NewFeature Something to build that is a new item.
Projects
Status: Done
Development

No branches or pull requests

7 participants