Skip to content

Support private openHAB Cloud instances via proxy URL discovery#1068

Merged
digitaldan merged 2 commits intodevelopfrom
fix/729-proxy-url-discovery
Feb 12, 2026
Merged

Support private openHAB Cloud instances via proxy URL discovery#1068
digitaldan merged 2 commits intodevelopfrom
fix/729-proxy-url-discovery

Conversation

@timbms
Copy link
Copy Markdown
Contributor

@timbms timbms commented Feb 11, 2026

Summary

Fixes #729

  • Resolve cloud proxy URL dynamically via GET /api/v1/proxyurl instead of hardcoding myopenhab.orghome.myopenhab.org rewrites
  • Replace hostname-based auth checks (hasSuffix("myopenhab.org")) with the supportsNotifications configuration flag across all auth middleware
  • Delete dead SessionChallengeHandler class (never instantiated)

What this enables

  • Private cloud users: Configure their cloud URL (e.g., https://cloud.example.com) with "openHAB Cloud Service" toggle on → app calls /api/v1/proxyurl to discover the correct web UI URL
  • Official myopenhab.org users: Same flow — endpoint returns https://home.myopenhab.org:443, falls back gracefully if unavailable
  • Local-only connections: Unaffected — supportsNotifications is false, proxy URL is never fetched

Files changed

File Change
NetworkTracker.swift Add proxyURL to ConnectionInfo, add fetchProxyURL() helper, resolve after connection test
OpenHABWebViewController.swift Use proxy URL in modifyUrl(), use supportsNotifications flag for cloud detection
SessionChallengeHandler.swift Use proxy URL host for auth challenges, delete dead class
AuthorisationMiddleware.swift Use supportsNotifications instead of hostname check
HTTPClient.swift Use supportsNotifications instead of hostname check
OpenHABAccessTokenAdapter.swift Use supportsNotifications instead of hostname check

Test plan

  • Build succeeds (verified)
  • Unit tests pass (verified)
  • Manual: configure https://myopenhab.org as remote → verify proxy URL is fetched and web view loads home.myopenhab.org
  • Manual: configure a private cloud URL with "openHAB Cloud Service" enabled → verify proxy URL API is called and returned URL is used
  • Manual: disconnect or use invalid cloud URL → verify graceful fallback
  • Manual: local-only connection (no remote) still works without proxy URL fetch

Replace hardcoded myopenhab.org hostname checks with dynamic proxy URL
resolution using the /api/v1/proxyurl endpoint, enabling private
openHAB Cloud instances to work correctly with the app.

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

I know supportsNotifications is part of the existing stored preferences, but i wonder if for future proofing this we create a property on the active config for isCloudConnection or something like that. For the time being it can internally check if supportsNotifications is true or not, but then the rest of the code does not have to depend on this preference name which is confusing to read (and i totally understand i probably wrote that hack in the first place) .

Wrap supportsNotifications behind a semantic isCloudConnection property
so the rest of the codebase doesn't depend on the preference name.

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

timbms commented Feb 11, 2026

I could  also update the Preferences filter to use isCloudConnection. @digitaldan : Let me know

@digitaldan
Copy link
Copy Markdown
Contributor

Whatever you think is best 👍

@timbms
Copy link
Copy Markdown
Contributor Author

timbms commented Feb 12, 2026

For the moment I would leave it as is. We could change it when we redo the Preferences loading to become more flexible.

@timbms
Copy link
Copy Markdown
Contributor Author

timbms commented Feb 12, 2026

@digitaldan: who could test it? I am not running a private openHAB Could instance.

@digitaldan
Copy link
Copy Markdown
Contributor

I can test it, but it should work exactly the same with out production service, right? It will pull the proxy host from the api? I'm actually working on a huge migration to typescript on the cloud service right at this moment so can give it a try since i have that up and running.

1 similar comment
@digitaldan
Copy link
Copy Markdown
Contributor

I can test it, but it should work exactly the same with out production service, right? It will pull the proxy host from the api? I'm actually working on a huge migration to typescript on the cloud service right at this moment so can give it a try since i have that up and running.

@digitaldan
Copy link
Copy Markdown
Contributor

I can confirm this works with a custom server 👍

@timbms
Copy link
Copy Markdown
Contributor Author

timbms commented Feb 12, 2026

Can we merge it?

@digitaldan digitaldan merged commit e6b76fa into develop Feb 12, 2026
2 checks passed
@digitaldan digitaldan deleted the fix/729-proxy-url-discovery branch February 12, 2026 16:36
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.

MainUI Hardcoded to home.myopenhab.org for Private OpenHabCloud

2 participants