Add persistent admin password login and deploy verified release

This commit is contained in:
tongtong committed 2026-11-26 10:24:05 +08:00
1 parent beeca041ef
commit bf424102c8
12 files changed
+319 -35

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
set -euo pipefail
cd /opt/vibe-launcher
STAGE=$(mktemp -d /opt/vibe-launcher/deploy8.XXXXXXXX)
mkdir -p "$STAGE/target"
cp target/vibe-launcher-backend.jar "$STAGE/target/"
cp Dockerfile "$STAGE/"
cp -p auth.env "$STAGE/auth.env.backup"
python3 - <<'PY'
from pathlib import Path
import secrets
p = Path('/opt/vibe-launcher/auth.env')
s = p.read_text()
if 'ADMIN_USERNAME=' not in s: s += '\nADMIN_USERNAME=admin\n'
if 'ADMIN_PASSWORD=' not in s: s += 'ADMIN_PASSWORD=' + secrets.token_urlsafe(24) + '\n'
p.write_text(s)
p.chmod(0o600)
PY
kubectl -n vibe-launcher create secret generic vibe-launcher-auth --from-env-file=auth.env --dry-run=client -o yaml | kubectl apply -f -
docker build -t docker.io/library/vibe-launcher-backend:1.1.0-deploy8 "$STAGE"
docker save docker.io/library/vibe-launcher-backend:1.1.0-deploy8 | k3s ctr images import -
kubectl apply -f deploy.yaml
if ! kubectl -n vibe-launcher rollout status deploy/vibe-launcher-backend --timeout=180s; then
kubectl -n vibe-launcher set image deploy/vibe-launcher-backend server=docker.io/library/vibe-launcher-backend:1.1.0-deploy7
exit 1
fi
bash verify.sh
python3 verify-login.py
+1 -1
View File
@@ -26,7 +26,7 @@ spec:
spec:
containers:
- name: server
image: docker.io/library/vibe-launcher-backend:1.1.0-deploy7
image: docker.io/library/vibe-launcher-backend:1.1.0-deploy8
imagePullPolicy: IfNotPresent
ports:
- name: http
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
"""Verify deployed password login without logging credentials or changing layouts."""
import http.cookiejar
import json
import os
from pathlib import Path
import urllib.request
import urllib.error
base = os.environ.get('BASE', 'https://api.ttstd.com/launcher').rstrip('/')
auth = dict(line.split('=', 1) for line in Path(os.environ.get('AUTH_FILE', '/opt/vibe-launcher/auth.env')).read_text().splitlines() if '=' in line and not line.startswith('#'))
jar = http.cookiejar.CookieJar()
client = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))
def request(path, expected=200, body=None, method=None, csrf=True):
headers = {'Content-Type': 'application/json'}
if csrf: headers['X-Launcher-Request'] = '1'
req = urllib.request.Request(base + path, data=json.dumps(body).encode() if body is not None else None, headers=headers, method=method)
try: response = client.open(req, timeout=15)
except urllib.error.HTTPError as error: response = error
assert response.code == expected, (path, response.code, expected)
data = response.read()
print(path, response.code)
return response.headers, data
request('/api/auth/session', 401)
request('/api/auth/login', 403, {}, csrf=False)
request('/api/auth/login', 401, {'username': auth['ADMIN_USERNAME'], 'password': 'invalid'})
headers, _ = request('/api/auth/login', body={'username': auth['ADMIN_USERNAME'], 'password': auth['ADMIN_PASSWORD']})
for attribute in ['HttpOnly', 'Secure', 'SameSite=Strict', 'Max-Age=2592000']:
assert attribute in headers['Set-Cookie'], attribute
request('/api/auth/session')
request('/api/admin/layout')
request('/api/admin/widget-providers')
request('/api/admin/history')
request('/api/admin/layout', 403, {}, method='PUT', csrf=False)
request('/api/admin/layout', 428, {}, method='PUT')
request('/api/layout', 401) # browser admin login must not authorize device API
request('/api/auth/logout', body={})
request('/api/auth/session', 401)
request('/api/admin/layout', 401)
print('Password login, cookie flags, authenticated reads, CSRF, device isolation and logout verified.')