mirror of
https://gitlab.w-hs.de/an14051/backerup-website.git
synced 2026-07-27 17:35:29 +00:00
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.
This commit is contained in:
@@ -1,36 +1,88 @@
|
||||
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||
# Backerup Website
|
||||
|
||||
## Getting Started
|
||||
The official website and sharing hub for [Backerup](https://github.com/evan-buss/backerup) — a self-hosted Docker container backup tool.
|
||||
|
||||
First, run the development server:
|
||||
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
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
cd frontend
|
||||
bun install
|
||||
bun run dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
The site is available at <http://localhost:3000>.
|
||||
|
||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||
> 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.
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||
## Deployment
|
||||
|
||||
## Learn More
|
||||
See [SETUP.md](./SETUP.md) for full Docker deployment instructions, environment variable reference, and first-login steps.
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
## Project Structure
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||
## Link Configuration
|
||||
|
||||
## Deploy on Vercel
|
||||
All external URLs (GitHub, Docker image, docs) live in one place:
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
```
|
||||
frontend/lib/links.ts
|
||||
```
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||
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 |
|
||||
|
||||
Reference in New Issue
Block a user