Repository navigation
Allow re-authenticating a server from settings - #6128
Merged
Merged
Conversation
1 of 7 tasks
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Undefined test macros block compilation, credential replacement can race with an existing refresh, and Catalyst certificate import omits the established presentation workaround.
3 open issues
What changed in this PR
Adds settings-based re-authentication for existing Home Assistant servers without removing their configuration, reusing the recovered-server login flow.
Changes:
- Adds re-authentication actions in Server Details and server context menus, with URL selection and certificate import.
- Shares token replacement logic and reloads the affected frontend after sign-in.
- Adds localized labels and tests for authentication, presentation, and settings updates.
| File | Description |
|---|---|
| Tests/App/WebView/WebViewControllerTests.swift | Tests recovery from the logged-out state after re-authentication. |
| Tests/App/Settings/ServerReauthenticationModifier.test.swift | Tests picker, certificate, login, and error presentation. |
| Tests/App/Settings/ServerReauthenticationModel.test.swift | Tests settings authentication state and outcomes. |
| Tests/App/Settings/ConnectionSettingsViewModel.test.swift | Tests certificate updates from server changes. |
| Tests/App/Settings/ConnectionSettingsView.test.swift | Adds progress-state snapshot coverage and search verification. |
| Tests/App/Container/ServerReauthenticatorTests.swift | Tests shared token replacement and redirect handling. |
| Tests/App/Container/RecoveredServerReauthViewModelTests.swift | Updates the certificate-check test dependency. |
| Tests/App/Container/OnboardingStateObservableTests.swift | Updates shared authentication test dependencies. |
| Sources/Shared/Resources/Swiftgen/Strings.swift | Adds generated re-authentication string accessors. |
| Sources/App/Settings/Settings/ServersListView.swift | Adds the context-menu action and presentation modifier. |
| Sources/App/Settings/Connection/ServerReauthenticationModifier.swift | Presents authentication steps and errors. |
| Sources/App/Settings/Connection/ServerReauthenticationModel.swift | Coordinates server-scoped authentication state. |
| Sources/App/Settings/Connection/ConnectionSettingsViewModel.swift | Keeps the displayed certificate synchronized. |
| Sources/App/Settings/Connection/ConnectionSettingsView.swift | Adds the re-authentication section and search entry. |
| Sources/App/Resources/en.lproj/Localizable.strings | Adds English re-authentication labels and guidance. |
| Sources/App/Frontend/WebView/WebViewController/WebViewController+URLLoading.swift | Registers for re-authentication notifications. |
| Sources/App/Frontend/WebView/WebViewController/WebViewController+ReAuth.swift | Resets authentication state and reloads the frontend. |
| Sources/App/Container/ServerReauthenticator.swift | Extracts reusable server re-authentication logic. |
| Sources/App/Container/OnboardingStateObservable.swift | Delegates recovered-server authentication to the shared helper. |
| HomeAssistant.xcodeproj/project.pbxproj | Updates membership exceptions for the new settings files. |
Review effort: Balanced
Comment on lines
+58
to
+59
| server.update { serverInfo in | ||
| serverInfo.token = tokenInfo |
|
|
||
| model.start(for: server) | ||
|
|
||
| #expectawait (waitUntil { controller.presentedViewController != nil }) |
Comment on lines
+23
to
+24
| .sheet(item: model.certificateRequestBinding(for: server)) { | ||
| RecoveredServerClientCertificateImportView(request: $0, asSheet: true) |
…eet for certificates on Mac
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6128 +/- ##
==========================================
+ Coverage 57.48% 57.60% +0.12%
==========================================
Files 1278 1282 +4
Lines 84565 84727 +162
==========================================
+ Hits 48614 48811 +197
+ Misses 35951 35916 -35
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


AI Policy
Select exactly one option that describes AI usage in this contribution:
Summary
Adds a way to sign in to a server again without removing it, for example after a password change or to switch users.
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#1462
Any other notes