Enable auth by default 🙈 (#16107)

* Enable auth by default

* Only default legacy_api_password if api_password set

* Tweak bool check

* typing
This commit is contained in:
Paulus Schoutsen 2018-08-23 13:38:08 +02:00 committed by GitHub
parent 249981de96
commit d21d7cef4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 3 deletions

View file

@ -407,7 +407,8 @@ def _format_config_error(ex: vol.Invalid, domain: str, config: Dict) -> str:
async def async_process_ha_core_config(
hass: HomeAssistant, config: Dict) -> None:
hass: HomeAssistant, config: Dict,
has_api_password: bool = False) -> None:
"""Process the [homeassistant] section from the configuration.
This method is a coroutine.
@ -416,9 +417,18 @@ async def async_process_ha_core_config(
# Only load auth during startup.
if not hasattr(hass, 'auth'):
auth_conf = config.get(CONF_AUTH_PROVIDERS)
if auth_conf is None:
auth_conf = [
{'type': 'homeassistant'}
]
if has_api_password:
auth_conf.append({'type': 'legacy_api_password'})
setattr(hass, 'auth', await auth.auth_manager_from_config(
hass,
config.get(CONF_AUTH_PROVIDERS, []),
auth_conf,
config.get(CONF_AUTH_MFA_MODULES, [])))
hac = hass.config