realm / realm-core

Core database component for the Realm Mobile Database SDKs
https://realm.io
Apache License 2.0
1.02k stars 165 forks source link

RCORE-2253 Redirected user authenticated app requests cause user to be logged out and location is not updated #8011

Open michael-wb opened 2 months ago

michael-wb commented 2 months ago

What, How & Why?

Updated the test http transport to enable HTTP redirection support in the Curl lib and added a test to verify the redirect operation. The Authorization header is not being included in the request when it is forwarded to the new location URL, leading the User to be logged out when a user authenticated appservices requests is performed. As a result, the handle_auth_failure() function was updated to request the location prior to refreshing the access token when an authenticated request fails on the first attempt, in order to ensure the client app is always connecting to the correct server hostname.

Added a test that is run when using the redirect server, that verifies the HTTP and websocket redirect operations since this support has been removed from App and has been enabled in the Curl lib used by the test harness.

The RedirectingHttpServer was updated to enable more control of the hostname and ws_hostname values returned by the location response and support was added to force a redirect response when an appservices request is received. An event hook was also added to be notified when a location request, http redirect, websocket redirect or error occurred.

Fixes #8008, #8012

☑️ ToDos

coveralls-official[bot] commented 2 months ago

Pull Request Test Coverage Report for Build michael.wilkersonbarker_1387

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
test/object-store/util/test_file.cpp 1 5 20.0%
test/object-store/sync/app.cpp 154 169 91.12%
test/object-store/util/sync/redirect_server.hpp 56 73 76.71%
<!-- Total: 222 258 86.05% -->
Files with Coverage Reduction New Missed Lines %
src/realm/query_expression.hpp 1 93.81%
src/realm/sync/network/websocket.cpp 1 72.2%
src/realm/sync/noinst/server/server_history.cpp 1 62.92%
src/realm/util/serializer.cpp 1 90.43%
src/realm/uuid.cpp 1 98.48%
test/fuzz_tester.hpp 1 57.73%
test/test_table.cpp 1 99.51%
src/realm/array_blobs_big.cpp 2 98.58%
src/realm/list.cpp 2 87.37%
src/realm/mixed.cpp 2 86.46%
<!-- Total: 65 -->
Totals Coverage Status
Change from base Build 2602: -0.005%
Covered Lines: 217392
Relevant Lines: 238621

💛 - Coveralls
jedelbo commented 1 month ago

@jbreams should this just be closed or is there anything valuable to preserve?