parent
eceef82ffa
commit
fee1568a85
4 changed files with 16 additions and 2 deletions
|
@ -51,6 +51,8 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_SERVER_HOST = "0.0.0.0"
|
DEFAULT_SERVER_HOST = "0.0.0.0"
|
||||||
DEFAULT_DEVELOPMENT = "0"
|
DEFAULT_DEVELOPMENT = "0"
|
||||||
|
# To be able to load custom cards.
|
||||||
|
DEFAULT_CORS = "https://cast.home-assistant.io"
|
||||||
NO_LOGIN_ATTEMPT_THRESHOLD = -1
|
NO_LOGIN_ATTEMPT_THRESHOLD = -1
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ HTTP_SCHEMA = vol.Schema(
|
||||||
vol.Optional(CONF_SSL_CERTIFICATE): cv.isfile,
|
vol.Optional(CONF_SSL_CERTIFICATE): cv.isfile,
|
||||||
vol.Optional(CONF_SSL_PEER_CERTIFICATE): cv.isfile,
|
vol.Optional(CONF_SSL_PEER_CERTIFICATE): cv.isfile,
|
||||||
vol.Optional(CONF_SSL_KEY): cv.isfile,
|
vol.Optional(CONF_SSL_KEY): cv.isfile,
|
||||||
vol.Optional(CONF_CORS_ORIGINS, default=[]): vol.All(
|
vol.Optional(CONF_CORS_ORIGINS, default=[DEFAULT_CORS]): vol.All(
|
||||||
cv.ensure_list, [cv.string]
|
cv.ensure_list, [cv.string]
|
||||||
),
|
),
|
||||||
vol.Inclusive(CONF_USE_X_FORWARDED_FOR, "proxy"): cv.boolean,
|
vol.Inclusive(CONF_USE_X_FORWARDED_FOR, "proxy"): cv.boolean,
|
||||||
|
|
|
@ -45,6 +45,9 @@ def setup_cors(app, origins):
|
||||||
|
|
||||||
path = path.canonical
|
path = path.canonical
|
||||||
|
|
||||||
|
if path.startswith("/api/hassio_ingress/"):
|
||||||
|
return
|
||||||
|
|
||||||
if path in cors_added:
|
if path in cors_added:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -232,3 +232,12 @@ async def test_ssl_profile_change_modern(hass):
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(mock_context.mock_calls) == 1
|
assert len(mock_context.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
async def test_cors_defaults(hass):
|
||||||
|
"""Test the CORS default settings."""
|
||||||
|
with patch("homeassistant.components.http.setup_cors") as mock_setup:
|
||||||
|
assert await async_setup_component(hass, "http", {})
|
||||||
|
|
||||||
|
assert len(mock_setup.mock_calls) == 1
|
||||||
|
assert mock_setup.mock_calls[0][1][1] == ["https://cast.home-assistant.io"]
|
||||||
|
|
|
@ -103,7 +103,7 @@ def test_secrets(isfile_patch, loop):
|
||||||
assert res["components"].keys() == {"homeassistant", "http"}
|
assert res["components"].keys() == {"homeassistant", "http"}
|
||||||
assert res["components"]["http"] == {
|
assert res["components"]["http"] == {
|
||||||
"api_password": "abc123",
|
"api_password": "abc123",
|
||||||
"cors_allowed_origins": [],
|
"cors_allowed_origins": ["https://cast.home-assistant.io"],
|
||||||
"ip_ban_enabled": True,
|
"ip_ban_enabled": True,
|
||||||
"login_attempts_threshold": -1,
|
"login_attempts_threshold": -1,
|
||||||
"server_host": "0.0.0.0",
|
"server_host": "0.0.0.0",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue