Add authentication to error log endpoint (#13836)
This commit is contained in:
parent
d3b261a25d
commit
20ababec3e
2 changed files with 46 additions and 3 deletions
|
@ -52,9 +52,8 @@ def setup(hass, config):
|
|||
hass.http.register_view(APIComponentsView)
|
||||
hass.http.register_view(APITemplateView)
|
||||
|
||||
log_path = hass.data.get(DATA_LOGGING, None)
|
||||
if log_path:
|
||||
hass.http.register_static_path(URL_API_ERROR_LOG, log_path, False)
|
||||
if DATA_LOGGING in hass.data:
|
||||
hass.http.register_view(APIErrorLog)
|
||||
|
||||
return True
|
||||
|
||||
|
@ -356,6 +355,17 @@ class APITemplateView(HomeAssistantView):
|
|||
HTTP_BAD_REQUEST)
|
||||
|
||||
|
||||
class APIErrorLog(HomeAssistantView):
|
||||
"""View to fetch the error log."""
|
||||
|
||||
url = URL_API_ERROR_LOG
|
||||
name = "api:error_log"
|
||||
|
||||
async def get(self, request):
|
||||
"""Retrieve API error log."""
|
||||
return await self.file(request, request.app['hass'].data[DATA_LOGGING])
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_services_json(hass):
|
||||
"""Generate services data to JSONify."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue