Async bcryptjs measured to still not yield the event loop for realistic
hash costs (~70ms compares finish before its 100ms yield threshold), so
a login flood could still stall the same process's live MegaPay payment
webhooks. Caps each client (or shared-proxy-bucket, see known limitation
below) to 5 POST /admin/login attempts per rolling 60s window via
express-rate-limit; requests over the limit get a 429 with a Vietnamese
error and never reach adminAuth.login, so the bcrypt compare never runs.
Known limitation: this app has no app.set('trust proxy', ...) configured
and runs behind a reverse proxy in production, so express-rate-limit's
default req.ip-based bucketing will key off the proxy's address, not the
real client IP. In production this enforces "5 attempts/minute in
aggregate behind the proxy" rather than "5 per real client IP" — an
accepted trade-off for this low-traffic internal tool, but not the same
guarantee trust proxy + per-IP limiting would give. Configuring trust
proxy is an infrastructure change, left out of scope here.
| Name |
Last commit
|
Last update |
|---|---|---|
| app | Loading commit data... | |
| config | Loading commit data... | |
| docs/superpowers | Loading commit data... | |
| log | Loading commit data... | |
| public | Loading commit data... | |
| .bowerrc | Loading commit data... | |
| .csslintrc | Loading commit data... | |
| .dockerignore | Loading commit data... | |
| .editorconfig | Loading commit data... | |
| .env.example | Loading commit data... | |
| .gitignore | Loading commit data... | |
| .jshintrc | Loading commit data... | |
| CLAUDE.md | Loading commit data... | |
| Dockerfile | Loading commit data... | |
| LICENSE.md | Loading commit data... | |
| MGP_Merchant_Interface_V1.4.7VN.md | Loading commit data... | |
| README.md | Loading commit data... | |
| bower.json | Loading commit data... | |
| deploy.md | Loading commit data... | |
| docker-compose.yml | Loading commit data... | |
| gruntfile.js | Loading commit data... | |
| karma.conf.js | Loading commit data... | |
| package-lock.json | Loading commit data... | |
| package.json | Loading commit data... | |
| server.js | Loading commit data... |