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

Remove child proxying for web authentication workflow #2710

Merged
merged 10 commits into from
Feb 7, 2025

Conversation

juanscr
Copy link
Contributor

@juanscr juanscr commented Jan 31, 2025

Description

This pull requests secures the authenticate function by removing all code that used child proxying. As such, now both web and non-web hosts will use the same authentication flow, relaying to the parent the full responsibility for executing the authentication capability.

Main changes in the PR:

  1. Remove child proxying from the authenticate workflow for web hosts.
  2. Improve all tests by adding null assertions in order to avoid cluttering the file with type errors that are meaningless.

Validation

Validation performed:

Validated through automated testing with unit and E2E tests.

For manual testing, I first tested in Edge/Chromium in a test client by disabling network caching, using a simulated 3G network and changed CPU throttling to the available values (0x, 4x, 6x and 20x slowdown). For all cases, the authentication window opened successfully. On Firefox, there isn't currently a way to throttle CPU, but it does allow for network throttling which I tested good 3G, slow 3G, good 2G and slow 2G. On all cases, the authentication window didn't get blocked. Initial tests on Safari shows the window opening properly.

Unit Tests added:

Yes

End-to-end tests added:

No

Additional Requirements

Change file added:

Yes

@juanscr juanscr requested a review from a team as a code owner January 31, 2025 19:40
@juanscr juanscr changed the title Remove web authentication flow for authenticate callback Remove child proxying for web authentication workflow Jan 31, 2025
@AE-MS
Copy link
Contributor

AE-MS commented Jan 31, 2025

"Haven't done manual tests yet."
Is that something you'll do before merging this PR?

@AE-MS
Copy link
Contributor

AE-MS commented Jan 31, 2025

Is everyone in agreement that we can merge this change without first adding any additional UX for users in Safari and/or Firefox who might experience pop-up blocking?

@jadahiya-MSFT
Copy link
Contributor

Is everyone in agreement that we can merge this change without first adding any additional UX for users in Safari and/or Firefox who might experience pop-up blocking?

How does this affect iOS where, from my understanding, the browsers are still Safari underneath?

@juanscr
Copy link
Contributor Author

juanscr commented Jan 31, 2025

Is everyone in agreement that we can merge this change without first adding any additional UX for users in Safari and/or Firefox who might experience pop-up blocking?

Good question! On the dev plan, we opted to start with refactoring this issue mainly so apps can benefit in security sooner, without having to wait on other work being done. We can backtrack that decision ofc, but I still strongly feel having auth as secure as possible is something to stride for.

@juanscr
Copy link
Contributor Author

juanscr commented Jan 31, 2025

Is everyone in agreement that we can merge this change without first adding any additional UX for users in Safari and/or Firefox who might experience pop-up blocking?

How does this affect iOS where, from my understanding, the browsers are still Safari underneath?

By iOS do you mean the native clients or people using Safari to login to Teams and stuff like that? Because native clients would still behave as usual, and they don't have any issue with pop-up blocking.

@juanscr
Copy link
Contributor Author

juanscr commented Jan 31, 2025

"Haven't done manual tests yet." Is that something you'll do before merging this PR?

Yes, I wanted to get some reviews for this first to test the waters a bit to see if there is a glaring issue in this refactoring. I will do some more thorough manual testing on Monday, as I want to run the tests in different browsers, my phone and in Mac and will update PR with findings.

For now, as short-sighted as automated testing can be, at least all the unit tests I coded and the older E2E tests pass which is a good signal that it may haven't break anything.

jadahiya-MSFT
jadahiya-MSFT previously approved these changes Jan 31, 2025
@juanscr
Copy link
Contributor Author

juanscr commented Feb 3, 2025

@AE-MS just updated the PR description with my results of some manual testing.

@AE-MS
Copy link
Contributor

AE-MS commented Feb 3, 2025

Is everyone in agreement that we can merge this change without first adding any additional UX for users in Safari and/or Firefox who might experience pop-up blocking?

Good question! On the dev plan, we opted to start with refactoring this issue mainly so apps can benefit in security sooner, without having to wait on other work being done. We can backtrack that decision ofc, but I still strongly feel having auth as secure as possible is something to stride for.

I know we had discussed switching child proxying to be opt-in rather than the current state (force-in, I guess) so that if any apps were depending on it, they can still use it for a period of time while the product itself can be secure by default. I guess I wasn't sure whether the same opt-in stance also applied to the auth window change.

@AE-MS
Copy link
Contributor

AE-MS commented Feb 3, 2025

@AE-MS just updated the PR description with my results of some manual testing.

Is it worth getting someone on a Mac to try this to see what happens? I think we know the expected result (pop-up blocked) which is fine but then I guess it goes back to my other comment about whether the opt-in stance also applies to the auth window changes.

@juanscr
Copy link
Contributor Author

juanscr commented Feb 4, 2025

@AE-MS just updated the PR description with my results of some manual testing.

Is it worth getting someone on a Mac to try this to see what happens? I think we know the expected result (pop-up blocked) which is fine but then I guess it goes back to my other comment about whether the opt-in stance also applies to the auth window changes.

Yes, let me ping someone in engineering if they can run the test by themselves. I wouldn't think that it would get blocked, the test client I am using (of what I noticed) pretty much opens the window "immediately" as there isn't many things executing at once. Therefore, the Safari strict requirement of opening in the time frame of 100 milliseconds would be fulfilled, therefore opening the window. In essence, I tried replicating busy event loop by the chromium cpu throttling but that of course is just an approximation of a real scenario.

@juanscr
Copy link
Contributor Author

juanscr commented Feb 4, 2025

Is everyone in agreement that we can merge this change without first adding any additional UX for users in Safari and/or Firefox who might experience pop-up blocking?

Good question! On the dev plan, we opted to start with refactoring this issue mainly so apps can benefit in security sooner, without having to wait on other work being done. We can backtrack that decision ofc, but I still strongly feel having auth as secure as possible is something to stride for.

I know we had discussed switching child proxying to be opt-in rather than the current state (force-in, I guess) so that if any apps were depending on it, they can still use it for a period of time while the product itself can be secure by default. I guess I wasn't sure whether the same opt-in stance also applied to the auth window change.

Got it! At least for now, I would think it isn't worth the risk to have opt-in for auth. Is not like that it will break authentication in web entirely, at least for what my research and tests show. There are just some cases in which the event loop and massive requests will end up blocking the pop-up which before it wouldn't have happened. On the contrary, removing child proxying will unequivocally break some apps and we don't want to remove support entirely.

AE-MS
AE-MS previously approved these changes Feb 5, 2025
Copy link
Contributor

@AE-MS AE-MS left a comment

Choose a reason for hiding this comment

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

:shipit:

@AE-MS
Copy link
Contributor

AE-MS commented Feb 5, 2025

Just left one suggestion in the unit tests for you to consider; might make the code cleaner.

@juanscr juanscr requested a review from AE-MS February 5, 2025 21:46
Copy link
Contributor

@AE-MS AE-MS left a comment

Choose a reason for hiding this comment

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

:shipit:

@juanscr juanscr enabled auto-merge (squash) February 6, 2025 15:35
Copy link
Contributor

github-actions bot commented Feb 6, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/teams-js/dist/esm/packages/teams-js/src/index.js 180.39 KB (-0.95% 🔽) 3.7 s (-0.95% 🔽) 802 ms (+82.76% 🔺) 4.5 s

@juanscr juanscr removed the request for review from jadahiya-MSFT February 6, 2025 15:37
@juanscr juanscr merged commit d09b02e into main Feb 7, 2025
58 checks passed
@juanscr juanscr deleted the juancard/fixAuthFlow branch February 7, 2025 19:37
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.

3 participants