Skip to content

Fix web view authentication challenges#1129

Closed
timbms wants to merge 747 commits intodevelopfrom
fix/webview-authentication
Closed

Fix web view authentication challenges#1129
timbms wants to merge 747 commits intodevelopfrom
fix/webview-authentication

Conversation

@timbms
Copy link
Copy Markdown
Contributor

@timbms timbms commented Apr 7, 2026

Summary

  • Adds alwaysSendSameAuthenticationToWebView to HomePreferences — when enabled, server credentials are forwarded to all web view authentication challenges regardless of host
  • Automatically forwards credentials when the challenge host matches a configured server URL or is home.myopenhab.org, with no setting change required
  • Adds a toggle in Connection Settings (visible when not in demo mode) to control the opt-in behaviour
  • Adds a custom Codable decoder to HomePreferences using decodeIfPresent for all fields, ensuring existing users don't lose their preferences when new keys are introduced

Fixes #1034

Test plan

  • Webview pointing to a resource on the same host as the openHAB server loads correctly without enabling the toggle
  • Webview pointing to a resource on a different host (e.g. embedded Grafana on same IP but different path) loads correctly after enabling "Always send credentials to web views"
  • Remote connection through home.myopenhab.org authenticates web views correctly without enabling the toggle
  • Toggling the setting off reverts to default-handling for unmatched hosts
  • Existing user preferences survive an app update (no data loss)

timbms and others added 30 commits February 1, 2026 20:17
Update logic skips refreshing the widget's type, leading to stale types showing as switches instead of charts; adding type assignment during updates should fix the display inconsistency.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
adjust the slider binding to reflect the live widget value when not dragging, and sync the internal state when editing starts.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
keep the row visible by separating the visible content from the Menu label, and overlaying a clear hit target

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Refactor watchOS row views to use widget.type directly (matching iOS pattern)
instead of the legacy stateEnum. Add TextRow for text widget support.

- Add TextRow.swift for watchOS text widget display
- Refactor SwitchRow to use local @State for toggle state
- Refactor SegmentRow/SegmentSelectionView to use local @State for selection
- Update SitemapPageView.rowWidget to switch on widget.type
- Remove WidgetTypeEnum, stateEnum, and stateEnumBinding from OpenHABWidget

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Add SelectionRow.swift with SelectionListView for selection widget support
- Add disclosure indicator (chevron) to TextRow when widget has linkedPage
- Use chevronUpChevronDown icon for SelectionRow matching iOS style

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Change IconWithAction to use Button instead of onTapGesture for reliable tap handling in List rows
- Add disabled state and grayed out styling to watchOS SetpointRow buttons at min/max values
- Use widget.unit as fallback when creating NumberState for dimension items
- Include unit in log messages for better debugging

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Make TextLabelView configurable with optional font and lineLimit
parameters so it can be shared between platforms. iOS defaults to
body font with lineLimit 1, while watchOS explicitly uses caption
font with lineLimit 2 to preserve existing behavior.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- SegmentedRowView: Move spacer inside conditional to avoid gap when
  there's no value label
- ColorSelection: Remove redundant type annotation
- Add CommonUI Package.resolved

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Use Color(fromString:) from CommonUI to properly parse hex color
strings like "#00AA00". The previous code used Color(widget.valuecolor)
which doesn't handle hex strings, causing values with custom colors
to not display.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Add fallbackSymbol parameter to IconView for SF Symbol fallback
  when network icons are unavailable (useful for previews)
- Add fallbackSymbol parameter to SegmentedRowView, forwarded to IconView
- Create PreviewList helper to reduce boilerplate in previews
- Update previews to use List with proper insets matching SitemapPageView
- Scale fallback symbol to 75% for better visual match with network icons

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Fix iOS SliderRowView not reacting to external updates by using
  debounce pattern (matching watchOS approach)
- Merge SliderWithSwitchSupportRow into SliderRow on watchOS
- Add fallbackSymbol support to watchOS IconView for previews
- Improve slider previews with minValue/maxValue/step support

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Use onEditingChanged for true release-only behavior on iOS
- Show current slider value while dragging on iOS and watchOS
- Fix external update handling with proper isEditing tracking
- Keep pendingValue until server responds to avoid visual jump

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Wrap PreviewConstants in #if DEBUG to exclude from release builds
- Fix SegmentedRowView preview detail labels to use numeric values

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Apply consistent styling with rounded background and border
- Add pressed indicator on each button
- Use equal spacing and minimum width for buttons

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Style singleMappingButton as momentary press button
- Match height, width, and indicator styling with segmentedButtons
- Set common minWidth on both single and pressRelease containers
- Add all widget types to All Scenarios preview

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Use trailing-aligned frame for single mapping button
- Use fixedSize with leading padding for pressRelease buttons

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Add isNilOrEmpty computed property on Optional<String>
- Replace verbose nil/empty checks in SegmentedRowView

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Move background/border to each pressRelease button
- Add spacing between buttons
- Match row height with segmentedButtons
- Add two-button pressRelease preview

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Add Office Shutter two-button pressRelease preview
- Restore consistent Spacer logic for button alignment

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Align iOS behavior with Android by highlighting the single mapping
button when the item's state matches the mapping command.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Always send slider value on release, not just in releaseOnly mode
- Add step parameter to Slider to match watchOS and prevent continuous
  vs step-adjusted value mismatch
- Only clear pendingValue when server confirms the value we sent,
  preventing jumps from intermediate throttled responses

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Simplify the drag gesture to send the command immediately on touch
instead of waiting for release, removing the pressed state tracking.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Guard against repeated sends in onChanged by tracking singlePressed
state. Add press/release visual feedback and selection animation.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
timbms and others added 28 commits March 12, 2026 20:11
Replace NumberFormatter (with invalid "US" locale) with
Float(_:format:) using en_US_POSIX for reliable decimal parsing.
Add CGFloatExtensionTests covering basic division, decimal input,
locale robustness, invalid strings, and edge cases.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
…ingTests

Replace legacy DateFormatter.iso8601Full with JSONDecoder.makeISO8601TolerantDecoder()
which uses Date.ISO8601FormatStyle. Update HTTPClient to use the new decoder.
Add comprehensive DateFormattingTests covering ISO8601 parsing, round-trip,
JSON decoding, log formatting, screensaver time, and notification timestamp formats.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Replace legacy regex and NumberFormatter usage in StringExtension with
modern Swift equivalents. Add comprehensive StringExtensionTests covering
doubleValue, intValue, numberValue, and asDouble parsing behaviour.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Without it, internal members (doubleValue, intValue, etc.) are
inaccessible from the test target.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
The ASAN configuration was the only one, forcing all runs to use Address
Sanitizer. This caused 'Undefined symbol: ___asan_alloca_poison' because
the host app binary isn't built with ASAN instrumentation. Add a plain
default 'Test' configuration; ASAN remains available for explicit use.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Add OTHER_LDFLAGS = -undefined dynamic_lookup to the test target so the
linker defers resolution of dynamic framework symbols (SDWebImageSVGCoder,
etc.) to runtime, where they are already loaded by the host app.

Also remove the redundant SDImageSVGCoder registration in OpenHABSVGTests
setUpWithError — AppDelegate already registers the coder before tests run.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Replace 'import SDWebImageSVGCoder' with ObjC runtime lookup via
NSClassFromString("SDImageSVGCoder"). This eliminates the hard link-time
dependency on SDWebImage data symbols (_SDImageCoderDecodePreserveAspectRatio
etc.) that BUNDLE_LOADER and -undefined dynamic_lookup cannot reliably resolve.

The coder is already registered by AppDelegate before any tests run,
so runtime lookup is sufficient. Also revert the -undefined dynamic_lookup
OTHER_LDFLAGS added in the previous commit.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
- Add OpenAPIErrorInspector utility to OpenHABCore, centralising all
  ClientError unwrapping so callers don't need to import OpenAPIRuntime
- Remove OpenAPIRuntime imports from SitemapPageViewModel and
  SingleConnectionSettingsView; replace ClientError casts with inspector
- Add SDWebImage as explicit Package.swift dependency (required now that
  OpenHABCore uses SDWebImage APIs directly)
- Add process(data:) convenience on OpenHABImageProcessor for test use
- Migrate OpenHABSVGTests from XCTest to Swift Testing (@Suite/@Test/#expect)
  and replace fragile ObjC-runtime SDImageSVGCoder lookup with direct
  OpenHABImageProcessor call via @testable import OpenHABCore
- Add dedicated openHABTestsSwift.xctestplan; point openHABTestsSwift
  scheme at it; remove ASAN config from openHABTests plan

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
The Main UI script editor height does not account for the bottom
toolbar's safe area padding on iPhone, causing the last 2-3 lines
to be hidden behind the toolbar and unreachable by scrolling.

Inject a JavaScript fix via WKWebView that adds bottom padding to
the page content and CodeMirror scroll container equal to the native
safe area inset plus any FAB button height. A MutationObserver
re-applies the fix on SPA navigation back to the script editor page.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
CI uses testplan: 'openHABTests' in the Fastfile unittests lane, but the
scheme only had openHABTestsSwift.xctestplan associated, causing xcodebuild
to error with 'Scheme does not have an associated test plan named openHABTests'.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
ASan instrumentation causes undefined symbol errors (___asan_alloca_poison)
when Swift Package Manager dependencies are not recompiled with ASan support.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Signed-off-by: openhab-bot <info@openhabfoundation.org>
…1102)

* Fix empty string commands and switch sendItemCommand to JSON payload

Text input items can now be cleared by submitting an empty string. Previously,
empty commands were silently dropped in both InputCommandFormatter and
WidgetCommandDispatcher. The guard order in InputCommandFormatter.command() is
corrected so that only number hints reject empty input; text hints pass through
an empty string as a valid "clear" command.

Also fixes the openapi.json schema for sendItemCommand, which incorrectly
declared the application/json body as type:string. It is now type:object with a
required "value" field, matching the actual server contract. Types.swift and
OpenAPIService are regenerated/updated accordingly.

---------

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Signed-off-by: openhab-bot <info@openhabfoundation.org>
Resolve conflicts:
- ETagCheckerTests.swift: place reset() before override class funcs
- contents.xcworkspacedata: include both CommonUI and ControlItemIntent.swift

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Tassilo Karge <tassilo.karge@web.de>
The git auto-merge of openapigen-swiftui dropped the sourceTree and
closing brace for the AppIntents PBXGroup, leaving an unmatched '{'.
Restore the missing two lines to fix the parse error.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
* Localisation transition to String Catalog

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Correction for build failure and functionality with missing .xcodeproj

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Make Colour Temperatures localisable

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Update Intents.intentdefinition

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Update Ruby and lockfile

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Add missing localisations for Debug strings and French Bonjour strings

Propagate "Debug" (untranslated) to es, fi, fr, it, nb, nl, ru for two
existing keys; add French translations for "Discovering openHAB servers"
and "No servers found".

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>

* German typo fixes

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Additional German translations

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* More German translations

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Further localisation adjustments

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Add missing 'Loading…' translations for es, fi, fr, it, nb, nl, ru

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>

* Port LocalizationTests to Swift Testing, drop tests superseded by String Catalog

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>

* Localisation and test adjustments

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Make Settings popups localisable

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* String adjustment

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Splitting up localisable string "empty" for gender specific translations

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Add missing localised string and minor string fixes

- Add `invalid_connection_configuration` key used in OpenHABCore with
  translations for all supported languages
- Fix German hyphenation for certificate-related strings
- Add Dutch translations for notifications and off strings

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>

* German correction for empty.value translation

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Additional watchOS 'empty' string made localisable

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Fixed German quotation marks

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

* Certificates dialogs buttons stringa adjustments

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>

---------

Signed-off-by: DigiH <17110652+DigiH@users.noreply.github.com>
Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Co-authored-by: Tim Mueller-Seydlitz <timbms@gmail.com>
…Tests

- Remove ControlItemIntent.swift from workspace (invalid workspace entry;
  individual Swift files don't belong in contents.xcworkspacedata)
- Remove openHABIntentsTests PBXGroup and its SetSwitchStateIntentHandlerTests.swift
  reference (folder was deleted in openapigen-swiftui branch)

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Resolve modify/delete conflicts: keep deletions of openHABIntents handler
files, which were replaced by the App Intents migration in this branch.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Resolves conflicts from the openapigen-swiftui SwiftUI migration landing in develop:

- OpenAPIService: adopt text/plain for non-empty commands, JSON for empty (compat with OH 4.x+5.x)
- NumberState: use develop's robust normalizedFormat parser
- WatchTypography / Watch rows: adopt labelColor/valueColor support
- AppDelegate: move setupFirebase() earlier to avoid Crashlytics silent session
- OHTextTokenStyle: keep 44pt minimum hit target (Apple HIG)
- StringExtension: use ";base64," separator for data URI parsing
- Localizable.xcstrings, CHANGELOG, Package.resolved, Gemfile.lock: accept develop state
- Remove old intent handler files deleted by migrateToAppIntents2
- Accept develop's reorganised file locations (ScreenSaver, SettingsView, Resources)

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Remove stale PBXFileReference and PBXBuildFile entries for the old
openHAB/Resources/Localizable.xcstrings path. The file is now at
openHAB/Supporting Files/Localizable.xcstrings and is picked up
automatically by the PBXFileSystemSynchronizedRootGroup for the openHAB
folder, so the old manual entries caused a 'Cannot have multiple
Localizable.xcstrings files in same target' build error.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Remove stale PBXFileReference pointing to the deleted root-level
../MainLaunchScreen.xib. The file now lives at openHAB/MainLaunchScreen.xib
and is included automatically via PBXFileSystemSynchronizedRootGroup.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
The openHAB directory is managed by PBXFileSystemSynchronizedRootGroup,
which automatically includes all files. The project also had 107 individual
PBXBuildFile entries in the Sources phase and several in the Resources phase
for the same files, causing 'Multiple commands produce' build errors for
every Swift file and several resource files.

Remove all stale individual entries; the sync group handles them.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
…nces

- Delete openHAB/SwiftUI/ (duplicate of openHAB/UI/SwiftUI/), openHAB/SitemapPageViewModel*.swift (duplicates of openHAB/Models/), and empty openHAB/Images.xcassets; all were branch-added files not present on develop and caused "Multiple commands produce" errors via PBXFileSystemSynchronizedRootGroup
- Remove stale PBXFileReference/PBXGroup/PBXBuildFile entries from project.pbxproj for the deleted files, the non-existent openHAB/AppIcon.icon (causing actool crash), and the stale openHABIntents/Intents.intentdefinition root-level reference (causing linker failure); keep the working Base.lproj/Intents.intentdefinition reference

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
…r user opt-in

Adds alwaysSendSameAuthenticationToWebView to HomePreferences so users can
opt in to sending server credentials to all web view authentication challenges.
Without the flag, credentials are still forwarded automatically when the
challenge host matches a configured server URL or is home.myopenhab.org.

Also adds a custom Codable decoder to HomePreferences using decodeIfPresent
for all fields to ensure backward compatibility when new keys are introduced.

Fixes #1034

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
@timbms
Copy link
Copy Markdown
Contributor Author

timbms commented Apr 7, 2026

Superseded by ##1130

@timbms timbms closed this Apr 7, 2026
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.

Webviews using authentication aren't working anymore

3 participants