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
+2 -8
View File
@@ -22,6 +22,7 @@ from typing import Any
import requests
from strix.config.loader import load_settings
from strix.utils.secret_files import write_secret_text
logger = logging.getLogger(__name__)
@@ -115,15 +116,8 @@ def is_verified() -> bool:
def write_auth(email: str, token: str, verified_at: str) -> None:
"""Atomically persist the auth record with 0600 permissions."""
AUTH_PATH.parent.mkdir(parents=True, exist_ok=True)
payload = json.dumps({"email": email, "token": token, "verified_at": verified_at})
tmp = AUTH_PATH.with_suffix(".json.tmp")
tmp.write_text(payload, 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, payload)
def forget() -> None: