Create credential files with owner-only permissions (#945)

Co-authored-by: Ahmed Allam <ahmed39652003@gmail.com>
This commit is contained in:
Tech Guy
2026-08-03 19:36:59 -07:00
committed by GitHub
co-authored by Ahmed Allam
parent 5bb9fe896b
commit 23f1d76d4c
5 changed files with 103 additions and 20 deletions
+3 -8
View File
@@ -24,6 +24,8 @@ from typing import TYPE_CHECKING, Any
import requests
from strix.utils.secret_files import write_secret_text
if TYPE_CHECKING:
from collections.abc import Iterator
@@ -67,14 +69,7 @@ def _read_store() -> dict[str, Any]:
def _write_store(data: dict[str, Any]) -> None:
AUTH_PATH.parent.mkdir(parents=True, exist_ok=True)
tmp = AUTH_PATH.with_suffix(".json.tmp")
tmp.write_text(json.dumps(data, indent=2), encoding="utf-8")
with contextlib.suppress(OSError):
tmp.chmod(0o600)
tmp.replace(AUTH_PATH)
with contextlib.suppress(OSError):
AUTH_PATH.chmod(0o600)
write_secret_text(AUTH_PATH, json.dumps(data, indent=2))
def read_record() -> dict[str, Any] | None: