Fix external auth reconnection loop if connection lost after refresh token expiration#8279
Merged
bramkragten merged 3 commits intohome-assistant:devfrom Jan 29, 2021
Merged
Fix external auth reconnection loop if connection lost after refresh token expiration#8279bramkragten merged 3 commits intohome-assistant:devfrom
bramkragten merged 3 commits intohome-assistant:devfrom
Conversation
* This happens when the refresh token is expired
bramkragten
reviewed
Jan 29, 2021
bramkragten
approved these changes
Jan 29, 2021
* Maybe the data is also helpful on a reject, therefore reject uses the data object
bramkragten
pushed a commit
that referenced
this pull request
Jan 29, 2021
…token expiration (#8279)
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Breaking change
Proposed change
This PR fixes the bug described in the issue #7732. This bug was introduced with PR #7236.
The external auth module (which is used by the companion apps (iOS/Android)) doesn't survive a lost connection if the refresh token is expired. The process is fully described in the issue #7732
The problem occurs frequently more on devices which doesn't close/suspend the app if not used and therefore doesn't force close the connection by closing/suspending the app.
Type of change
Example configuration
For better debugging, I lowered the refresh token expiration from 30 minutes to 1 minute in HA here:
https://github.com/home-assistant/core/blob/ac3a6aaa8cdb005b3c900f9d9671e5a859351060/homeassistant/auth/const.py#L4
To reproduce this problem you need to disable "Close connection automatically" in the profile settings (only if you didn't lower the refresh token expiration time < 5 minutes) and use the Home Assistant Companion App (Then the external auth module is used)
3a. Alternatively you can try to trigger a fetch from HA with auth (which needs a new refresh token), by opening e.g. the history tab.
Now we are in a reconnection loop and the frontend cannot connect anymore.
You will see in the Home Assistant log continuously following messages (Be sure to enable the websocket debug logs in HA)
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: