Update PLANNING.md and CLAUDE.md to reflect current state

- Mark Phase 1, 2, 2.5, 3 as complete
- Add project structure diagram to PLANNING.md
- Update CLAUDE.md: correct file layout, session auth, safe config
  rewrite pattern, remove stale references to index.html and Basic Auth

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
marcandClaude Sonnet 4.6 committed 2026-06-19 22:30:13 +02:00
1 parent 5d9a9e62ec
commit 67dacd4044
2 files changed
+84 -79

No files matched your search

+56 -62
View File
@@ -30,81 +30,75 @@ on a second client). This app does not implement backup.
---
## Current state (baseline)
## Project structure
- `app.py` — Flask API: list/create SMB & NFS shares, set quotas.
- `index.html` — Bootstrap UI with SMB / NFS / Quotas tabs.
- `docker-compose.yml` — test sandbox.
### Known issues to fix
- `parse_smb()` is called (`app.py:13`) but never defined → `/api/shares` 500s.
- `subprocess.run(cmd, shell=True)` with f-string input (`app.py:82`) → command
injection as root.
- `add_smb_share` writes raw user input into `smb.conf` → config injection via
newlines.
- No authentication on any route.
- Config is append-only (`open(..., 'a')`) → no working delete/edit; UI Delete
buttons are wired to nothing.
- No input validation on names or paths (path traversal, share of `/`).
```
MicroNAS/
├── app.py Flask backend (all API routes + business logic)
├── templates/
│ ├── index.html Main SPA shell (Jinja2, no inline JS/CSS)
│ └── login.html Login form
├── static/
│ ├── css/app.css Custom dark theme (GitHub-palette CSS vars)
│ └── js/
│ ├── utils.js esc(), showToast(), apiFetch()
│ ├── dashboard.js loadDashboard()
│ ├── shares.js SMB/NFS CRUD + edit/delete/toggle
│ ├── quotas.js Quota modal
│ ├── users.js User CRUD + password modal
│ └── main.js Init + auto-refresh
├── micronas.service systemd unit
├── docker-compose.yml Dev/test sandbox only
├── README.md
└── PLANNING.md
```
---
## Roadmap
### Phase 1 — Correctness & safety (must-have)
- [ ] Implement `parse_smb()` so `/api/shares` works.
- [ ] Remove all `shell=True`; use argument-list `subprocess` calls.
- [ ] Validate input:
- share/user names: `^[A-Za-z0-9_-]+$`
- paths must resolve under `/srv`
- reject anything else with a clear error.
- [ ] Simple login: HTTP Basic Auth, single user + password from env var,
protecting all routes.
- [ ] `systemd` unit + `gunicorn`, plus README run instructions.
### Phase 1 — Correctness & safety ✅
- [x] Implement `parse_smb()` so `/api/shares` works.
- [x] Remove all `shell=True`; use argument-list `subprocess` calls.
- [x] Validate input: names `^[A-Za-z0-9_-]+$`; paths must resolve under `/srv`.
- [x] Session-based login (custom `/login` page, Flask sessions, secret key
derived from `MICRONAS_PASS`).
- [x] `systemd` unit + `gunicorn` + README install guide.
### Phase 2 — Dashboard & health (the main goal)
A landing page that shows the state of the server at a glance:
- [x] **Daemon status** — is `smbd` running? is `nfsd` running? (green/red).
- [x] **Disk usage** — free / used / total for `/srv`.
- [x] **All shares in one view** — every SMB share and NFS export, their paths,
and who can access them.
- [x] **Per-share data used** — size on disk of each share's path (`du`).
- [x] **Quota usage** — for each user with a quota: used vs limit, with a
progress bar.
- [x] Auto-refresh every 30 seconds + manual refresh button.
### Phase 2 — Dashboard & health ✅
- [x] **Daemon status** — smbd / nfsd running? (green/red dot).
- [x] **Disk usage** — free / used / total for `/srv` with progress bar.
- [x] **All shares in one view** — SMB + NFS, paths, access, size on disk.
- [x] **Per-share data used** — `du -sb` per share path.
- [x] **Quota usage** — per-user progress bars from `repquota`.
- [x] Auto-refresh every 30 s + manual refresh button.
### Phase 2.5 — UX improvements (next up)
Improvements identified after first real test:
### Phase 2.5 — UX improvements ✅
- [x] UI redesign — GitHub-dark palette, custom CSS vars, better contrast
and typography.
- [x] Inline quota management — "Quota" button per share row opens a modal
pre-filled with the share's valid users.
- [x] Toast notifications — replaced all `alert()`.
- [x] Frontend split into `templates/` + `static/css/` + `static/js/`.
- [x] User management tab — list users (uid ≥ 1000), create, delete,
change SMB password.
- [x] Login page — replaces browser Basic Auth dialog.
- [x] **UI redesign** — GitHub-dark palette, better contrast, card layout,
breathing room. Custom CSS variables, no extra dependencies.
- [x] **Inline quota management** — removed dedicated Quotas tab. Each SMB
share and NFS export row has a "Quota" button that opens a modal.
For SMB: lists valid_users with individual GB inputs. For NFS: manual
user + GB. Submits one API call per user in parallel.
- [x] **Toast notifications** — replaced all `alert()` with Bootstrap toasts.
- [x] **Auto-refresh every 30 s** (was 60 s).
- [ ] **User management tab** — create, delete, and change the SMB password
of NAS users without touching the command line:
- List all system users (uid ≥ 1000), show whether they have a Samba
account.
- Create user: `useradd -M -s /usr/sbin/nologin` + `smbpasswd -a`.
- Delete user: `smbpasswd -x` + `userdel`.
- Change SMB password: `smbpasswd -s` via modal.
- Backend: `/api/users` GET/POST, `/api/users/<name>` DELETE,
`/api/users/<name>/password` POST.
### Phase 3 — Full management (complete the CRUD)
- [ ] Working **delete** for SMB & NFS (parse config into blocks, rewrite the
### Phase 3 — Full share management ✅
- [x] Working **delete** for SMB & NFS (parse config into sections, rewrite
whole file — not append-only).
- [ ] **Edit** existing shares (path, valid users).
- [ ] Enable/disable a share without deleting it.
- [x] **Edit** existing shares — name, path, valid users (SMB); clients,
ro/rw (NFS). Edit modal pre-filled with current values.
- [x] **Enable/disable** a share without deleting it — SMB uses
`available = no`; NFS comments out the export line.
- [x] Status indicator per share row (green/red dot, reduced opacity when
disabled).
### Phase 4 — Nice-to-have
- [ ] **WebDAV** support. Preferred approach: don't build it in Flask — have the
app drop an Apache/nginx WebDAV config snippet, same pattern as SMB/NFS,
so it reuses the existing architecture.
- [ ] **WebDAV** support. Preferred approach: drop an Apache/nginx config
snippet — don't build it in Flask.
- [ ] Simple in-browser file browser for `/srv`.
- [ ] Auto-create share directory on add (with correct owner/permissions).
---