A full-stack password manager: store service credentials safely behind a master account. React (Vite) front end talking to an Express + PostgreSQL API that encrypts every stored password with AWS KMS envelope encryption and protects sessions with JWT + CSRF double-submit cookies.
- Register / log in with a master password (hashed with bcrypt, salt rounds 10)
- Store, view, search, edit and delete service passwords
- Cryptographically secure password generator (
crypto.getRandomValues) - Change account email or master password; delete your account (cascades to stored passwords)
- Change-audit log for every create/update/delete and account change
- Sessions expire after 1 hour
| Concern | How it is handled |
|---|---|
| Stored passwords at rest | Each password is encrypted with AES-256-GCM under its own data key; the key is generated by AWS KMS and only the encrypted key is stored (server/encryptionUtils.js, server/kmsUtils.js) |
| Master passwords | bcrypt hash with 10 salt rounds; never stored or transmitted in plaintext |
| Sessions | JWT in an httpOnly / Secure / SameSite=Strict cookie, verified on every protected request |
| CSRF | Double-submit: the (non-httpOnly) csrf cookie must match an X-CSRF-Token header and be a token signed with the server secret (server/middleware.js) |
| SQL injection | Parameterised queries throughout |
| Brute force / enumeration | Sliding-window rate limiting on login & registration; generic error messages; email normalisation |
| Ownership | Every password read/write is scoped to the authenticated user_id (IDOR-safe) |
| Data integrity | GCM auth tags detect any tampering with encrypted rows |
client/ React + Vite front end (components, hooks, utils)
server/ Express API
app.js routes + wiring
middleware.js JWT / CSRF verification, cookie helpers
rateLimiter.js sliding-window rate limiting
encryptionUtils.js AES-256-GCM + legacy CBC fallback
kmsUtils.js AWS KMS data-key generation / decryption
hashUtils.js bcrypt hashing
test/ unit tests (node --test)
- Node.js 18+
- PostgreSQL (see schema below)
- AWS KMS key (for encryption) — or run with the env vars pointing at your account/region
The schema is not managed by the app; create it once, for example:
CREATE TABLE users (
user_id SERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL
);
CREATE TABLE passwords (
password_id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
service_name TEXT NOT NULL,
password_encrypted TEXT NOT NULL,
encrypted_data_key TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE change_logs (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
password_id INTEGER NOT NULL REFERENCES passwords(password_id) ON DELETE CASCADE,
description TEXT NOT NULL,
timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE user_change_logs (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
description TEXT NOT NULL,
timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
);cd server
npm install
cp .env.example .env # create from the variables below
npm start # http://localhost:3000Environment variables:
PORT=3000
CLIENT_URL=http://localhost:5173
PG_USER=...
PG_HOST=localhost
PG_DATABASE=...
PG_PASSWORD=...
PG_PORT=5432
JWT_SECRET=<long random string>
CSRF_SECRET=<another long random string>
AWS_REGION=...
KMS_KEY_ID=...
COOKIE_SECURE=true # set to false for plain-HTTP local development
cd client
npm install
npm run dev # http://localhost:5173Set VITE_API_URL in client/.env if the API is not at http://localhost:3000/api.
Unit tests use the built-in Node test runner (no extra framework):
cd server
npm testThey cover encryption round-trips (incl. legacy-CBC fallback and tamper rejection), bcrypt hashing, JWT & CSRF middleware, cookie attributes and the rate limiter.
| Method & path | Auth | Purpose |
|---|---|---|
POST /api/registration |
– | Create account (rate-limited) |
POST /api/login |
– | Log in, sets session + csrf cookies (rate-limited) |
POST /api/removecookies |
– | Log out (clears both cookies) |
GET /api/csrftoken |
JWT | Refresh a stale CSRF token/cookie |
GET /api/getpasswords |
JWT+CSRF | List the user's decrypted passwords |
POST /api/createpassword |
JWT+CSRF | Store a new encrypted password |
PUT /api/updatepassword |
JWT+CSRF | Update a stored password |
DELETE /api/deletepassword/:id |
JWT+CSRF | Delete a stored password |
GET /api/getemail |
JWT+CSRF | Fetch the account email |
PUT /api/updateemail |
JWT+CSRF | Change the account email |
PUT /api/updateuserpassword |
JWT+CSRF | Change the master password |
DELETE /api/deleteuser |
JWT+CSRF | Delete the account and all its passwords |