Deprecate http.api_password (#21884)
* Deprecated http.api_password * Deprecated ApiConfig.api_password GitHub Drafted PR would trigger CI after changed it to normal PR. I have to commit a comment change to trigger it * Trigger CI * Adjust if- elif chain in auth middleware
This commit is contained in:
parent
7ec7e51f70
commit
fe1840f901
27 changed files with 304 additions and 324 deletions
|
@ -2,11 +2,12 @@
|
|||
import voluptuous as vol
|
||||
from voluptuous.humanize import humanize_error
|
||||
|
||||
from homeassistant.const import __version__
|
||||
from homeassistant.components.http.auth import validate_password
|
||||
from homeassistant.components.http.ban import process_wrong_login, \
|
||||
process_success_login
|
||||
from homeassistant.auth.providers import legacy_api_password
|
||||
from homeassistant.components.http.ban import (
|
||||
process_wrong_login,
|
||||
process_success_login,
|
||||
)
|
||||
from homeassistant.const import __version__
|
||||
|
||||
from .connection import ActiveConnection
|
||||
from .error import Disconnect
|
||||
|
@ -80,9 +81,15 @@ class AuthPhase:
|
|||
refresh_token.user, refresh_token)
|
||||
|
||||
elif self._hass.auth.support_legacy and 'api_password' in msg:
|
||||
self._logger.debug("Received api_password")
|
||||
if validate_password(self._request, msg['api_password']):
|
||||
user = await legacy_api_password.async_get_user(self._hass)
|
||||
self._logger.info(
|
||||
"Received api_password, it is going to deprecate, please use"
|
||||
" access_token instead. For instructions, see https://"
|
||||
"developers.home-assistant.io/docs/en/external_api_websocket"
|
||||
".html#authentication-phase"
|
||||
)
|
||||
user = await legacy_api_password.async_validate_password(
|
||||
self._hass, msg['api_password'])
|
||||
if user is not None:
|
||||
return await self._async_finish_auth(user, None)
|
||||
|
||||
self._send_message(auth_invalid_message(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue