mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Log successful and failed login attempts (#2347)
This commit is contained in:
parent
12e26d25a5
commit
3349bdc2bd
@ -1,4 +1,9 @@
|
|||||||
"""This module provides WSGI application to serve the Home Assistant API."""
|
"""
|
||||||
|
This module provides WSGI application to serve the Home Assistant API.
|
||||||
|
|
||||||
|
For more details about this component, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/http/
|
||||||
|
"""
|
||||||
import hmac
|
import hmac
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
@ -19,7 +24,7 @@ import homeassistant.util.dt as dt_util
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
DOMAIN = "http"
|
DOMAIN = "http"
|
||||||
REQUIREMENTS = ("eventlet==0.19.0", "static3==0.7.0", "Werkzeug==0.11.5",)
|
REQUIREMENTS = ("eventlet==0.19.0", "static3==0.7.0", "Werkzeug==0.11.5")
|
||||||
|
|
||||||
CONF_API_PASSWORD = "api_password"
|
CONF_API_PASSWORD = "api_password"
|
||||||
CONF_SERVER_HOST = "server_host"
|
CONF_SERVER_HOST = "server_host"
|
||||||
@ -395,7 +400,12 @@ class HomeAssistantView(object):
|
|||||||
self.hass.wsgi.api_password):
|
self.hass.wsgi.api_password):
|
||||||
authenticated = True
|
authenticated = True
|
||||||
|
|
||||||
if self.requires_auth and not authenticated:
|
if authenticated:
|
||||||
|
_LOGGER.info('Successful login/request from %s',
|
||||||
|
request.remote_addr)
|
||||||
|
elif self.requires_auth and not authenticated:
|
||||||
|
_LOGGER.warning('Login attempt or request with an invalid'
|
||||||
|
'password from %s', request.remote_addr)
|
||||||
raise Unauthorized()
|
raise Unauthorized()
|
||||||
|
|
||||||
request.authenticated = authenticated
|
request.authenticated = authenticated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user