-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Make HTTP origin value an instance member #12821
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
Conversation
| @@ -653,8 +652,7 @@ void WinRTHttpResource::AddResponseHandler(shared_ptr<IResponseHandler> response | |||
| client = HttpClient{redirFilter}; | |||
| } else { | |||
| auto globalOrigin = GetRuntimeOptionString("Http.GlobalOrigin"); | |||
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.
We should add a public PropertyId, or a setter for ReactPropertyBag/ReactInstanceSettings to allow setting this option on a per instance basis. If someone wanted to have different origins for different RN instances there would still be a synchronization issue here.
We still need the "legacy" GetRuntimeOptionString option for Office's non-abi code paths, but for public use this should all be done using ReactInstanceSettings.
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.
Can that be addressed in a follow-up PR? (I could use that to re-factor other property ID declarations that are done inefficiently).
This fix is required ASAP.
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.
Sure
* Make origin an instance member * Change files * Remove s_origin * Remove redundant namespace
* Make origin an instance member * Change files * Remove s_origin * Remove redundant namespace
* Make HTTP origin value an instance member (#12821) * Make origin an instance member * Change files * Remove s_origin * Remove redundant namespace * Remove change file * Change files * Add missing backports * Use case-insensitive comparison for CORS preflight responses (#11511) * Remove usage of RestoreUseStaticGraphEvaluation * Add test ValidatePreflightResponseHeadersCaseMismatchSucceeds * Use case-insensitive comparer for AllowedHeaders * Change files * Revert "Remove usage of RestoreUseStaticGraphEvaluation" This reverts commit 735b168. * Rename ConstWcharComparer to CaseInsensitiveComparer * Update vnext/Desktop.UnitTests/OriginPolicyHttpFilterTest.cpp Co-authored-by: Danny van Velzen <dannyvv@microsoft.com> * Remove unused code * Make ExposedHeaders case-insensitive --------- Co-authored-by: Danny van Velzen <dannyvv@microsoft.com> * Remove change file * clang format * Remove redundant include --------- Co-authored-by: Danny van Velzen <dannyvv@microsoft.com>
* Make HTTP origin value an instance member (#12821) * Make origin an instance member * Change files * Remove s_origin * Remove redundant namespace * Remove change file * Change files * Empty commit
Description
Sets HTTP origin URL per filter instance.
Type of Change
Why
A crash can be caused by an inconsistent state when the host app is being shut down and an HTTP request has been scheduled from the JS layer.
This affects the static member
OriginPolicyHttpFilter::s_origin.What
Make the HTTP origin an instance member of
OriginPolicyHttpFilterso the value will be bound to the filter's life time.In most cases, this won't add significant memory overhead because the filter's instance (and its members) is a singleton for the owning resource, module, and React instance.
Testing
Updated tests
ValidatePreflightResponseHeadersCaseMismatchSucceedsandValidatePreflightResponseMainAndContentHeadersSucceeds.Microsoft Reviewers: Open in CodeFlow