fix: allow insecure connections in iOS WidgetExtension #19863
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is a change to the WidgetExtension bundle for the iOS application to allow insecure connections. It mirrors the same values allowed on the main iOS application, that is, it allows any insecure connection.
This fixes cases similar to #19829 where an insecure server connection is attempted and the connection is rejected by the system. Currently if the Immich server is accessed via a local IP (such as 192.169.1.100) there is no issue as iOS won't safeguard the connection with App Transport Security (ATS). But if using a hostname, and in my case, accessing via an insecure Tailscale host (ie http://tailscale.ts.net) the widget connection fails. By changing the App Transport Security setting for the WidgetExtension to match the Application setting, this issue is resolved.
There are other options for ATS, though with servers provided via user input, a more strict allowance may be hard to manage. Since the primary app bundle allows arbitrary loads, I don't see an issue with using that same setting for the widget bundle. If there's ever a change to the app bundle, we'd probably want to keep this mirrored as well.
Potentially Fixes #19829 though in the provided image in that issue, it appears the server is secured, though I am not able to verify.
How Has This Been Tested?
I compiled and ran the code, and reproduced the issue using my insecure hostname which redirects to my local URL. This loads fine in the app, but fails in the iOS widget. Digging in and running via Xcode I added a catch to where the error was occurring and received the log indicating the failure:
With this clear message, I made the requested change that mirrors the app bundle settings for this same configuration.
With the change in place, recompiling and running allows the widgets to refresh and show images as expected.
Checklist:
src/services/uses repositories implementations for database calls, filesystem operations, etc.src/repositories/is pretty basic/simple and does not have any immich specific logic (that belongs insrc/services/)