-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Require admin for supervisor event publishing and addon options info #169325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
774dfa4
dd4c2e1
88f2d9c
6aa3c66
70f6eea
6252d52
59f4a74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| from . import SUPERVISOR_TOKEN | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| from tests.typing import ClientSessionGenerator | ||||||||||||||||||||||||||||||||||||||||||||||||||
| from tests.typing import ClientSessionGenerator, WebSocketGenerator | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.fixture(autouse=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -65,6 +65,25 @@ async def hassio_client_supervisor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.fixture | ||||||||||||||||||||||||||||||||||||||||||||||||||
| def hass_supervisor_ws_client( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| hass_ws_client: WebSocketGenerator, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| hass: HomeAssistant, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> WebSocketGenerator: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| """Return a websocket client authenticated as the Supervisor user.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| async def create_client() -> WebSocketGenerator: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| hassio_user_id = hass.data[DATA_CONFIG_STORE].data.hassio_user | ||||||||||||||||||||||||||||||||||||||||||||||||||
| hassio_user = await hass.auth.async_get_user(hassio_user_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| assert hassio_user | ||||||||||||||||||||||||||||||||||||||||||||||||||
| assert hassio_user.refresh_tokens | ||||||||||||||||||||||||||||||||||||||||||||||||||
| refresh_token = next(iter(hassio_user.refresh_tokens.values())) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| access_token = hass.auth.async_create_access_token(refresh_token) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+80
to
+81
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use the existing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't a drop-in replacement. I'm not entirely sure why at the moment. I'm guessing it has to do with this code: core/homeassistant/components/hassio/__init__.py Lines 220 to 243 in d62f136
Currently this fixture has zero usage throughout the I can probably fix it but this feels like a separate problem now. Given the context of the PR from the audit I think it would be better to just merge what we have that works and take a look at what's going on with the loading of the Supervisor user as a follow-up effort.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah it relies on the |
||||||||||||||||||||||||||||||||||||||||||||||||||
| return await hass_ws_client(hass, access_token=access_token) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+75
to
+82
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| return create_client | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.fixture | ||||||||||||||||||||||||||||||||||||||||||||||||||
| async def hassio_handler(hass: HomeAssistant) -> AsyncGenerator[HassIO]: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| """Create mock hassio handler.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the access restriction for
supervisor/eventwith the PR’s stated intent (admin-only) or update the PR title/description to reflect that this now requires the special Supervisor user.@ws_require_user(only_supervisor=True)blocks even regular admin users and returnsonly_supervisor, which is stricter than “require admin” and changes the documented breaking behavior.