Files
Anders Böttcher 0d58fafe4e feat: implement user authentication and admin management
- Add user management API endpoints for listing and creating users.
- Implement login and logout functionality with rate limiting.
- Create UI components for login form, logout button, and animated elements.
- Add session management with JWT and secure cookie handling.
- Seed initial admin user if no users exist.
- Introduce utility functions for password hashing and user authentication.
- Set up proxy middleware for route protection and security headers.
- Create a JSON file for user data storage.
- Add links configuration for external resources.
2026-05-12 14:58:11 +02:00

89 lines
3.3 KiB
Markdown

# Backerup Website
The official website and sharing hub for [Backerup](https://github.com/evan-buss/backerup) — a self-hosted Docker container backup tool.
Browse community-shared container configs and `.backerup` snapshots, upload your own, and copy restore commands in seconds.
## Features
- **Browse & search** — filter shared files by type, group, name, image, or description
- **Upload & share** — share `.backerup` snapshots and `.json` container configs via a unique link
- **One-click restore snippet** — Docker run commands generated from uploaded configs
- **Authentication** — JWT-based sessions with scrypt password hashing and rate-limited login
- **Admin panel** — create, delete, and manage user accounts with role-based access
- **Security headers** — `X-Frame-Options`, `HSTS`, `CSP`-ready, and more on every response
## Quick Start (Development)
**Prerequisites:** [Bun](https://bun.sh) >= 1.0
```bash
cd frontend
bun install
bun run dev
```
The site is available at <http://localhost:3000>.
> Auth is **disabled** in dev mode when `AUTH_SECRET` is not set — all routes are open.
> Set `AUTH_SECRET` and `ADMIN_PASSWORD` to test the full login flow locally.
## Deployment
See [SETUP.md](./SETUP.md) for full Docker deployment instructions, environment variable reference, and first-login steps.
## Project Structure
```
frontend/
app/
page.tsx # Landing page
browse/ # Browse & search shared files
share/ # Upload form
files/[token]/ # Individual file detail + download
login/ # Login page
admin/ # Admin user management panel
api/
auth/ # POST /login, POST /logout
files/ # GET file list, GET/download by token
upload/ # POST file upload
admin/users/ # Admin user CRUD
components/ # AnimateIn, CountUp, SpotlightCard, TerminalTyper, LogoutButton
lib/
auth.ts # scrypt password hashing
session.ts # JWT session create/verify/delete
users.ts # User CRUD (stored in data/users.json)
store.ts # File metadata + upload storage
links.ts # Centralised external URL config
data/ # Runtime data (gitignored except .gitkeep)
meta.json # File record index
users.json # User accounts (hashed credentials only)
uploads/ # Uploaded files organised by token
docker/
Dockerfile # Multi-stage build (deps → builder → slim runner)
docker-compose.yml # Single-service compose with named volume
build.sh # Build helper
deploy.sh # Deploy helper
```
## Link Configuration
All external URLs (GitHub, Docker image, docs) live in one place:
```
frontend/lib/links.ts
```
Edit that file and every button, footer link, and terminal snippet updates automatically.
## Tech Stack
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router, standalone output) |
| Runtime | Bun |
| Styling | Tailwind CSS v4 + custom CSS animations |
| Auth | scrypt (Node crypto) + HS256 JWT (jose) |
| Storage | Local filesystem (JSON index + raw files) |
| Container | Docker multi-stage, non-root user |