Skip to content

Commit 0b3b80e

Browse files
committed
feat: add admin session auth for dashboard
Protect dashboard data and admin browser actions behind collector-managed sessions, and align the new login flow with the existing dashboard design system.
1 parent a47180d commit 0b3b80e

File tree

12 files changed

+910
-33
lines changed

12 files changed

+910
-33
lines changed

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ LOG_DEBUG_EVENTS_MAX_PER_SYNC=200
2121
# Timezone offset from UTC (default: 7 for Vietnam)
2222
TIMEZONE_OFFSET_HOURS=7
2323

24+
# Admin dashboard auth (single shared admin password)
25+
ADMIN_PASSWORD=change-me
26+
ADMIN_SESSION_TTL_DAYS=30
27+
ADMIN_SESSION_COOKIE_NAME=cliproxy_admin_session
28+
ADMIN_SESSION_SECURE_COOKIE=false
29+
ADMIN_SESSION_SAMESITE=Lax
30+
# Optional comma-separated allowlist. Leave empty to allow same-origin host automatically.
31+
ADMIN_ALLOWED_ORIGINS=
32+
2433
# Frontend polling interval (seconds)
2534
VITE_AUTO_REFRESH_SECONDS=60
2635
VITE_APP_LOGS_PAGE_SIZE=500
36+
37+
# Optional: Lark MCP local setup (for Claude Code .mcp.json)
38+
LARK_APP_ID=cli_xxx
39+
LARK_APP_SECRET=your-lark-app-secret
40+
LARK_DOMAIN=https://open.larksuite.com
41+
LARK_TOOLSETS=preset.base,preset.task,task.v2.task.get,task.v2.task.list,task.v2.tasklist.list,task.v2.tasklist.tasks

README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,21 @@ Edit `.env`:
7171
DB_PASSWORD=your_secure_password_here
7272
CLIPROXY_URL=http://host.docker.internal:8317
7373
CLIPROXY_MANAGEMENT_KEY=<your-management-secret>
74+
ADMIN_PASSWORD=change-me
7475
7576
# Optional
7677
COLLECTOR_INTERVAL_SECONDS=300
7778
TIMEZONE_OFFSET_HOURS=7
79+
ADMIN_SESSION_TTL_DAYS=30
80+
ADMIN_SESSION_SECURE_COOKIE=false
81+
ADMIN_SESSION_SAMESITE=Lax
7882
```
7983

84+
Notes:
85+
- Dashboard now requires admin login before loading UI or `/rest/v1/*` data.
86+
- The browser stores only an `HttpOnly` session cookie; the password is never stored in browser storage.
87+
- If you deploy behind HTTPS, set `ADMIN_SESSION_SECURE_COOKIE=true`.
88+
8089
### 5) Start services
8190
```bash
8291
docker compose up -d
@@ -158,6 +167,47 @@ export CLIPROXY_COLLECTOR_URL="https://your-domain/api/collector/skill-events"
158167

159168
---
160169

170+
<details>
171+
<summary><h2>Optional: Lark Suite MCP + local skill</h2></summary>
172+
173+
This repo now includes templates to enable Lark task data access from Claude Code.
174+
175+
### 1) Prepare local MCP config (do not commit secrets)
176+
177+
```bash
178+
cp .mcp.json.example .mcp.json
179+
```
180+
181+
`.mcp.json` is ignored by git in this repo, so keep real credentials there.
182+
183+
### 2) Set local environment variables
184+
185+
Use your shell profile (or export in current terminal):
186+
187+
```bash
188+
export LARK_APP_ID="cli_xxx"
189+
export LARK_APP_SECRET="your-lark-app-secret"
190+
export LARK_DOMAIN="https://open.larksuite.com"
191+
export LARK_TOOLSETS="preset.base,preset.task,task.v2.task.get,task.v2.task.list,task.v2.tasklist.list,task.v2.tasklist.tasks"
192+
```
193+
194+
### 3) Reload Claude Code session
195+
196+
After saving `.mcp.json` and env vars, restart Claude Code (or reload) so `lark-mcp` can start.
197+
198+
### 4) Use repo-local skill
199+
200+
Skill file: `.claude/skills/lark-suite/SKILL.md`
201+
202+
Ask naturally, for example:
203+
- "Lấy danh sách task đang open trong Lark"
204+
- "Lấy chi tiết task theo ID ..."
205+
- "Tóm tắt task theo trạng thái"
206+
207+
</details>
208+
209+
---
210+
161211
<details>
162212
<summary><h2>Common operations</h2></summary>
163213

@@ -194,6 +244,10 @@ npm install
194244
npm run dev
195245
```
196246

247+
Open Vite dev UI at `http://localhost:5173`.
248+
249+
> Keep the local collector running too. Vite dev proxy now checks the same auth session flow as production, so `/rest/v1/*` stays locked until you log in.
250+
197251
### Collector (local)
198252

199253
```bash
@@ -221,7 +275,13 @@ python main.py
221275

222276
- Wait until first collection interval
223277
- Check collector logs: `docker compose logs -f collector`
224-
- Trigger manually: `curl -X POST http://localhost:8417/api/collector/trigger`
278+
- Trigger manually after logging in: `curl -X POST http://localhost:8417/api/collector/trigger`
279+
280+
### Login does not work
281+
282+
- Ensure `.env` contains `ADMIN_PASSWORD` and that it matches what you enter on the login screen
283+
- For HTTPS deployments, set `ADMIN_SESSION_SECURE_COOKIE=true`; for local HTTP keep it `false`
284+
- If you use a custom origin or reverse proxy, set `ADMIN_ALLOWED_ORIGINS` to the public dashboard origin
225285

226286
### PostgREST errors about missing schema
227287

0 commit comments

Comments
 (0)