https://github.com/shinniuwu/quickshield
This is a simple user management application built with Fastify, Prisma, and Node.js. It includes user registration, login, and password reset functionalities. The application is designed for personal use, but anyone is welcome to contribute and improve it!
https://github.com/shinniuwu/quickshield
api auth authentication contribute easyauth fastauth fastify nodejs performance prisma quickshield sql
Last synced: about 2 months ago
JSON representation
This is a simple user management application built with Fastify, Prisma, and Node.js. It includes user registration, login, and password reset functionalities. The application is designed for personal use, but anyone is welcome to contribute and improve it!
- Host: GitHub
- URL: https://github.com/shinniuwu/quickshield
- Owner: ShinniUwU
- License: gpl-3.0
- Created: 2024-10-28T23:01:00.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-28T23:08:56.000Z (over 1 year ago)
- Last Synced: 2025-04-03T23:23:10.520Z (about 1 year ago)
- Topics: api, auth, authentication, contribute, easyauth, fastauth, fastify, nodejs, performance, prisma, quickshield, sql
- Language: TypeScript
- Homepage:
- Size: 58.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# QuickShield — Fastify Auth Template
QuickShield is a minimal, secure starter for user authentication built on **Fastify**, **Prisma**, and **TypeScript** (runs great on **Bun**). It ships with cookie-based sessions, CSRF protection, rate-limiting, and automatic Swagger docs generated from TypeBox route schemas.
## Features
- User registration, login, logout, and profile (`/me`)
- Password reset via secure, one-time tokens
- Encrypted cookie sessions (`@fastify/secure-session`), no Redis required
- CSRF protection for state-changing routes
- Rate limiting and security headers (helmet)
- CORS allowlist via env
- OpenAPI/Swagger UI at `/docs` (from TypeBox schemas)
### CSRF usage
- Call `GET /csrf` to retrieve a CSRF token. The token is tied to your session.
- Send it in header `x-csrf-token` for any state-changing request (POST/PUT/PATCH/DELETE).
- Example:
```bash
curl -c cookie.txt http://localhost:3000/csrf
# => {"token":"..."}
curl -b cookie.txt -H "x-csrf-token: " -H "content-type: application/json" \
-X POST -d '{"email":"dev@example.com","password":"secret123"}' http://localhost:3000/login
```
## Stack
- Fastify, @sinclair/typebox, @fastify/swagger, @fastify/swagger-ui
- @fastify/secure-session, @fastify/csrf-protection, @fastify/helmet, @fastify/cors, @fastify/rate-limit
- Prisma ORM (+ @prisma/client)
- Argon2 password hashing (argon2id)
- Nodemailer email transport
## Getting Started
### Prerequisites
- Bun or Node.js 18+
- A relational DB (PostgreSQL recommended)
### Installation
1. **Clone the repository:**
```bash
git clone https://github.com/ShinniUwU/QuickShield.git
cd QuickShield
```
2. **Install dependencies:**
```bash
bun install
```
3. **Configure environment:**
Copy `.env.example` to `.env` and fill values. Generate a session secret:
```bash
cp .env.example .env
openssl rand -base64 32 # paste into SESSION_SECRET
```
4. **Run Prisma migrations:**
```bash
bunx prisma migrate dev --name init
```
5. **Start the server:**
```bash
bun run start
```
- API: `http://localhost:3000`
- Docs: `http://localhost:3000/docs`
### Endpoints
Documented at `/docs`. Core routes:
- POST `/register` — register user
- POST `/login` — start session (cookie)
- POST `/logout` — end session
- GET `/me` — current user
- POST `/forgot-password` — request reset link
- POST `/reset-password` — submit new password
### Dev SMTP (optional)
Run a local SMTP sink on port 2525 and point `.env` to it for testing emails:
```bash
bun run smtp:dev
```
### License
QuickShield is released under a permissive "Creditware" license.
You may use and modify it freely — including commercially — as long as
you give credit to the original QuickShield repository and don’t resell
it uncredited. See [LICENSE](./LICENSE) for full terms.
### Contributing
Fork the repo and open a PR. Please keep changes focused and documented.