🐛 fix(base.py): fix issue with loading and saving secret key in Settings class
🐛 fix(utils.py): fix issue with writing secret key to file in write_secret_to_file function
This commit is contained in:
parent
eacf558e70
commit
a8b9c08a9d
2 changed files with 5 additions and 1 deletions
|
|
@ -72,6 +72,10 @@ class Settings(BaseSettings):
|
|||
if secret_key_path.exists():
|
||||
value = read_secret_from_file(secret_key_path)
|
||||
logger.debug("Loaded secret key")
|
||||
if not value:
|
||||
value = secrets.token_urlsafe(32)
|
||||
write_secret_to_file(secret_key_path, value)
|
||||
logger.debug("Saved secret key")
|
||||
else:
|
||||
value = secrets.token_urlsafe(32)
|
||||
write_secret_to_file(secret_key_path, value)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ def set_secure_permissions(file_path):
|
|||
|
||||
def write_secret_to_file(path: Path, value: str) -> None:
|
||||
with path.open("wb") as f:
|
||||
f.write(value)
|
||||
f.write(value.encode("utf-8"))
|
||||
try:
|
||||
set_secure_permissions(path)
|
||||
except Exception:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue