From 50ef6749023b2d6b89b887ae904aa81f62da2142 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 8 Aug 2023 12:19:20 +0200 Subject: [PATCH] Use require_admin decorator for check_config permissions (#98028) --- homeassistant/components/config/core.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/config/core.py b/homeassistant/components/config/core.py index 5a825e5676a..9771e12f1d6 100644 --- a/homeassistant/components/config/core.py +++ b/homeassistant/components/config/core.py @@ -5,11 +5,10 @@ from typing import Any import voluptuous as vol from homeassistant.components import websocket_api -from homeassistant.components.http import HomeAssistantView +from homeassistant.components.http import HomeAssistantView, require_admin from homeassistant.components.sensor import async_update_suggested_units from homeassistant.config import async_check_ha_config_file from homeassistant.core import HomeAssistant -from homeassistant.exceptions import Unauthorized from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.util import location, unit_system @@ -29,11 +28,9 @@ class CheckConfigView(HomeAssistantView): url = "/api/config/core/check_config" name = "api:config:core:check_config" + @require_admin async def post(self, request): """Validate configuration and return results.""" - if not request["hass_user"].is_admin: - raise Unauthorized() - errors = await async_check_ha_config_file(request.app["hass"]) state = "invalid" if errors else "valid"