fix(auth): use _config_dir() in load_or_create_secret for consistent 0700 dir permissions
Replace bare path.parent.mkdir() (no mode, defaults to umask ~0755) with _config_dir() which always creates ~/.config/muxplex with mode=0o700. This matches the pattern already used by generate_and_save_password() and ensures the config directory is never left traversable by other users. Also update the module docstring to reflect that the module now manages both passwords and signing secrets.
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
muxplex authentication — password file management.
|
muxplex authentication — password and signing secret file management.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import secrets
|
import secrets
|
||||||
@@ -62,7 +62,7 @@ def load_or_create_secret() -> str:
|
|||||||
if path.exists():
|
if path.exists():
|
||||||
return path.read_text().strip()
|
return path.read_text().strip()
|
||||||
secret = secrets.token_urlsafe(32)
|
secret = secrets.token_urlsafe(32)
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
_config_dir() # ensures dir exists with mode 0700, consistent with generate_and_save_password()
|
||||||
path.write_text(secret + "\n")
|
path.write_text(secret + "\n")
|
||||||
path.chmod(0o600)
|
path.chmod(0o600)
|
||||||
return secret
|
return secret
|
||||||
|
|||||||
Reference in New Issue
Block a user