Move event permissions out of the websocket api into auth (#101975)

This commit is contained in:
J. Nick Koston 2023-10-15 11:14:19 -10:00 committed by GitHub
parent 3c3f512583
commit 93f10cdce8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 44 additions and 35 deletions

View file

@ -12,6 +12,7 @@ import voluptuous as vol
from homeassistant.auth.models import User
from homeassistant.auth.permissions.const import POLICY_READ
from homeassistant.auth.permissions.events import SUBSCRIBE_ALLOWLIST
from homeassistant.const import (
EVENT_STATE_CHANGED,
MATCH_ALL,
@ -128,10 +129,6 @@ def handle_subscribe_events(
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
) -> None:
"""Handle subscribe events command."""
# Circular dep
# pylint: disable-next=import-outside-toplevel
from .permissions import SUBSCRIBE_ALLOWLIST
event_type = msg["event_type"]
if event_type not in SUBSCRIBE_ALLOWLIST and not connection.user.is_admin: