mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 11:56:25 +01:00
Enable api transport encryption for new projects (#3142)
* Enable api transport encryption for new projects * Format
This commit is contained in:
parent
c569f5ddcf
commit
0b69f72315
@ -1,5 +1,6 @@
|
||||
# pylint: disable=wrong-import-position
|
||||
|
||||
import base64
|
||||
import codecs
|
||||
import collections
|
||||
import functools
|
||||
@ -378,6 +379,8 @@ class WizardRequestHandler(BaseHandler):
|
||||
if k in ("name", "platform", "board", "ssid", "psk", "password")
|
||||
}
|
||||
kwargs["ota_password"] = secrets.token_hex(16)
|
||||
noise_psk = secrets.token_bytes(32)
|
||||
kwargs["api_encryption_key"] = base64.b64encode(noise_psk).decode()
|
||||
destination = settings.rel_path(f"{kwargs['name']}.yaml")
|
||||
wizard.wizard_write(path=destination, **kwargs)
|
||||
self.set_status(200)
|
||||
|
@ -111,6 +111,8 @@ def wizard_file(**kwargs):
|
||||
# Configure API
|
||||
if "password" in kwargs:
|
||||
config += f" password: \"{kwargs['password']}\"\n"
|
||||
if "api_encryption_key" in kwargs:
|
||||
config += f" encryption:\n key: \"{kwargs['api_encryption_key']}\"\n"
|
||||
|
||||
# Configure OTA
|
||||
config += "\nota:\n"
|
||||
|
Loading…
Reference in New Issue
Block a user