mirror of
https://github.com/usestrix/strix.git
synced 2026-08-21 02:45:31 +02:00
Create credential files with owner-only permissions (#945)
Co-authored-by: Ahmed Allam <ahmed39652003@gmail.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user