Skip to content

Commit e13a2be

Browse files
committed
hide password + fix mac mkdir
1 parent a9bc437 commit e13a2be

5 files changed

Lines changed: 48 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ jobs:
7575
PY
7676
cat version.json
7777
78+
- name: Write auth.json from secret
79+
shell: bash
80+
env:
81+
AUTH_PASSWORD_HASH: ${{ secrets.AUTH_PASSWORD_HASH }}
82+
run: |
83+
if [ -z "$AUTH_PASSWORD_HASH" ]; then
84+
echo "ERROR: AUTH_PASSWORD_HASH secret not set; aborting build." >&2
85+
exit 1
86+
fi
87+
python -c "import json,os; json.dump({'password_sha256': os.environ['AUTH_PASSWORD_HASH']}, open('auth.json','w'))"
88+
7889
- name: Fetch Chrome for Testing
7990
shell: bash
8091
run: python build/fetch_chrome.py --platform ${{ matrix.chrome_plat }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ build/work/
1919
.env
2020
.env.*
2121
!.env.example
22+
auth.json
23+
secrets/
2224

2325
# OS
2426
.DS_Store

build/tixcraft.spec

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ datas += [
3737
(str(PROJECT_ROOT / "build" / "icons" / "icon.png"), "."),
3838
]
3939

40+
# auth.json holds the password hash. It's gitignored — CI writes it from the
41+
# AUTH_PASSWORD_HASH secret before invoking PyInstaller (see release.yml).
42+
_auth_file = PROJECT_ROOT / "auth.json"
43+
if _auth_file.exists():
44+
datas.append((str(_auth_file), "."))
45+
4046
ICON_ICNS = str(PROJECT_ROOT / "build" / "icons" / "icon.icns")
4147
ICON_ICO = str(PROJECT_ROOT / "build" / "icons" / "icon.ico")
4248

src/ui/widgets/auth_dialog.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
11
from __future__ import annotations
22
import hashlib
3+
import json
4+
import os
35

46
from PySide6.QtCore import Qt
57
from PySide6.QtWidgets import (
68
QDialog, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton,
79
QCheckBox,
810
)
911

12+
from ...utils import paths
13+
1014

11-
_PASSWORD_SHA256 = "30fa18a448f91d5558499fcf9e5c8fccf9f736b31d874629f38cd65f8feedcee"
1215
_MAX_ATTEMPTS = 5
16+
_AUTH_FILE = "auth.json"
17+
18+
19+
def _load_password_hash() -> str:
20+
"""Load the expected SHA-256 hash from (in order):
21+
1. env var AUTH_PASSWORD_HASH (for CI)
22+
2. bundled / dev-tree auth.json (gitignored)
23+
Returns empty string if missing -> verify() will always fail."""
24+
env = os.environ.get("AUTH_PASSWORD_HASH", "").strip().lower()
25+
if env:
26+
return env
27+
try:
28+
path = paths.find_resource(_AUTH_FILE)
29+
if path and path.exists():
30+
with open(path, "r", encoding="utf-8") as f:
31+
data = json.load(f)
32+
return str(data.get("password_sha256", "")).strip().lower()
33+
except Exception:
34+
pass
35+
return ""
1336

1437

1538
def verify(password: str) -> bool:
16-
# strip leading/trailing whitespace defensively (full-width spaces too)
39+
expected = _load_password_hash()
40+
if not expected:
41+
return False
1742
cleaned = password.strip().strip(" ")
18-
return hashlib.sha256(cleaned.encode("utf-8")).hexdigest() == _PASSWORD_SHA256
43+
return hashlib.sha256(cleaned.encode("utf-8")).hexdigest().lower() == expected
1944

2045

2146
class AuthDialog(QDialog):

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.2.3",
2+
"version": "0.2.4",
33
"name": "準點搶",
44
"publisher": "浩毅科技 HaoYi Tech",
55
"copyright": "© 2026 浩毅科技 HaoYi Tech"

0 commit comments

Comments
 (0)