fix: harden auth against brute force, add auth audit logging, fix cookie/TLS gaps
Security review findings (HIGH-1/2/3, MEDIUM): - Rate limiting via @nestjs/throttler: global 100 req/min default, stricter 10 req/min on login and refresh. Also closes the MEDIUM finding (public batch-lookup enumeration) since it now sits behind the global limit too. Trust the K8s ingress's single proxy hop so throttling keys off the real client IP, not the ingress pod's IP. - Auth events (login success/failure, logout, token refresh) are now audit-logged via new AuditAction values, closing the gap where the project's own audit-log principle never actually covered the Auth module. - Refresh-token cookie now defaults to Secure=true (opt out only via COOKIE_SECURE=false for local HTTP dev), instead of keying off NODE_ENV which was never set in the K8s deploy templates. Added a TLS block + cert-manager annotation to both the backend and frontend ingress templates, which previously had no HTTPS termination configured at all.
This commit is contained in:
1 parent
1a7331b6b2
commit
f1298eff08
16 files changed
+224
-15
No files matched your search
@@ -8,3 +8,4 @@ data:
|
||||
JWT_REFRESH_EXPIRES_IN: "7d"
|
||||
FRONTEND_ORIGIN: "https://apicore.example.com"
|
||||
DOCUMENTS_STORAGE_PATH: "/data/documents"
|
||||
COOKIE_SECURE: "true"
|
||||
@@ -4,8 +4,15 @@ metadata:
|
||||
name: apicore-backend
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /$2
|
||||
# Requires cert-manager with a ClusterIssuer named "letsencrypt-prod"
|
||||
# (or swap for whatever issuer/cert mechanism the cluster already uses).
|
||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
tls:
|
||||
- hosts:
|
||||
- api.apicore.example.com
|
||||
secretName: apicore-backend-tls
|
||||
rules:
|
||||
- host: api.apicore.example.com
|
||||
http:
|
||||
|
||||
@@ -2,8 +2,16 @@ apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: apicore-frontend
|
||||
annotations:
|
||||
# Requires cert-manager with a ClusterIssuer named "letsencrypt-prod"
|
||||
# (or swap for whatever issuer/cert mechanism the cluster already uses).
|
||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
tls:
|
||||
- hosts:
|
||||
- apicore.example.com
|
||||
secretName: apicore-frontend-tls
|
||||
rules:
|
||||
- host: apicore.example.com
|
||||
http:
|
||||
|
||||
Reference in new issue
Block a user