mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Remove supports_encryption check from mobile_app (#113490)
helpers already ports nacl at top level so this check can never be False ``` >>> import sys >>> from nacl.secret import SecretBox >>> assert nacl in sys.modules >>> ```
This commit is contained in:
parent
4df2398b9f
commit
c69495b64f
@ -143,16 +143,6 @@ def error_response(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def supports_encryption() -> bool:
|
|
||||||
"""Test if we support encryption."""
|
|
||||||
try:
|
|
||||||
import nacl # noqa: F401 pylint: disable=import-outside-toplevel
|
|
||||||
|
|
||||||
return True
|
|
||||||
except OSError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def safe_registration(registration: dict) -> dict:
|
def safe_registration(registration: dict) -> dict:
|
||||||
"""Return a registration without sensitive values."""
|
"""Return a registration without sensitive values."""
|
||||||
# Sensitive values: webhook_id, secret, cloudhook_url
|
# Sensitive values: webhook_id, secret, cloudhook_url
|
||||||
|
@ -35,7 +35,6 @@ from .const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
SCHEMA_APP_DATA,
|
SCHEMA_APP_DATA,
|
||||||
)
|
)
|
||||||
from .helpers import supports_encryption
|
|
||||||
from .util import async_create_cloud_hook
|
from .util import async_create_cloud_hook
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +76,7 @@ class RegistrationsView(HomeAssistantView):
|
|||||||
|
|
||||||
data[CONF_WEBHOOK_ID] = webhook_id
|
data[CONF_WEBHOOK_ID] = webhook_id
|
||||||
|
|
||||||
if data[ATTR_SUPPORTS_ENCRYPTION] and supports_encryption():
|
if data[ATTR_SUPPORTS_ENCRYPTION]:
|
||||||
data[CONF_SECRET] = secrets.token_hex(SecretBox.KEY_SIZE)
|
data[CONF_SECRET] = secrets.token_hex(SecretBox.KEY_SIZE)
|
||||||
|
|
||||||
data[CONF_USER_ID] = request["hass_user"].id
|
data[CONF_USER_ID] = request["hass_user"].id
|
||||||
|
@ -100,7 +100,6 @@ from .const import (
|
|||||||
DATA_DEVICES,
|
DATA_DEVICES,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
ERR_ENCRYPTION_ALREADY_ENABLED,
|
ERR_ENCRYPTION_ALREADY_ENABLED,
|
||||||
ERR_ENCRYPTION_NOT_AVAILABLE,
|
|
||||||
ERR_ENCRYPTION_REQUIRED,
|
ERR_ENCRYPTION_REQUIRED,
|
||||||
ERR_INVALID_FORMAT,
|
ERR_INVALID_FORMAT,
|
||||||
ERR_SENSOR_NOT_REGISTERED,
|
ERR_SENSOR_NOT_REGISTERED,
|
||||||
@ -115,7 +114,6 @@ from .helpers import (
|
|||||||
error_response,
|
error_response,
|
||||||
registration_context,
|
registration_context,
|
||||||
safe_registration,
|
safe_registration,
|
||||||
supports_encryption,
|
|
||||||
webhook_response,
|
webhook_response,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -484,13 +482,6 @@ async def webhook_enable_encryption(
|
|||||||
ERR_ENCRYPTION_ALREADY_ENABLED, "Encryption already enabled"
|
ERR_ENCRYPTION_ALREADY_ENABLED, "Encryption already enabled"
|
||||||
)
|
)
|
||||||
|
|
||||||
if not supports_encryption():
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Unable to enable encryption for %s because libsodium is unavailable!",
|
|
||||||
config_entry.data[ATTR_DEVICE_NAME],
|
|
||||||
)
|
|
||||||
return error_response(ERR_ENCRYPTION_NOT_AVAILABLE, "Encryption is unavailable")
|
|
||||||
|
|
||||||
secret = secrets.token_hex(SecretBox.KEY_SIZE)
|
secret = secrets.token_hex(SecretBox.KEY_SIZE)
|
||||||
|
|
||||||
update_data = {
|
update_data = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user