forked from mtusi2026/mtusi2026lab7
ЛР 7 — БВТ2302 — Макаренко — TLS и управление секретами
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import secrets
|
||||
from pathlib import Path
|
||||
|
||||
target = Path(__file__).resolve().parents[1] / ".env"
|
||||
if not target.exists():
|
||||
with target.open("x", encoding="utf-8") as output:
|
||||
for name in ("DB_PASSWORD","S3_PASSWORD"):
|
||||
output.write(f"{name}={secrets.token_hex(32)}\n")
|
||||
import json
|
||||
|
||||
config = dict(line.split("=",1) for line in target.read_text().splitlines() if "=" in line)
|
||||
local = target.parent / ".local"
|
||||
local.mkdir(exist_ok=True)
|
||||
identity = dict(name="messenger",credentials=[dict(accessKey="messenger",secretKey=config["S3_PASSWORD"])],actions=["Admin","Read","Write","List"])
|
||||
(local/"s3.json").write_text(json.dumps(dict(identities=[identity])),encoding="utf-8")
|
||||
Reference in New Issue
Block a user