You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge: PR #42 from sameboat-platform/feat/week-3-checkout
This pull request introduces several backend hardening features focused on authentication, session management, and documentation. The most important changes are the addition of password complexity enforcement during registration, in-memory login rate limiting with a new error code, scheduled session pruning, and comprehensive documentation updates reflecting these improvements. Integration tests have been added for all major new features.
- Documentation: `docs/RISKS.md` and `docs/spikes/jwt-session-tradeoffs.md`.
12
+
- Public version endpoint `GET /api/version` that returns the deployed version (from JAR manifest when available, falling back to `project.version`).
13
+
- Spring profiles for development and production:
14
+
-`dev`: in-memory H2, relaxed cookies (host-only, `Secure=false`), and CORS including `http://localhost:5173`.
15
+
-`prod`: Postgres/Neon, secure cookies (domain + `Secure=true`), explicit CORS allowlist.
16
+
- CORS configuration via `CorsConfig` and Security chain `.cors()`; credentials enabled and origins restricted to configured list.
17
+
- CI release job on tag push (`v*`): builds JAR and attaches it to a GitHub Release using `softprops/action-gh-release@v1`.
18
+
19
+
### Changed
20
+
-`README.md`: Documented password policy, `RATE_LIMITED` error code, and updated sample passwords; linked to new docs.
21
+
-`docs/api.md`: Updated error codes, register/login behavior, and added pruning notes.
22
+
-`Architecture.md`: Reflected opaque sessions, rate limiting, password policy, and pruning.
23
+
-`CONTRIBUTING.md`: Included `RATE_LIMITED` in error codes and noted password complexity under security.
24
+
- Unified Actuator base path to `/actuator` across profiles; health and info remain exposed publicly via security rules. Legacy `/api/actuator/*` references were removed from tests/config where applicable.
- Input validation tightened on auth payloads (`@Valid` + Bean Validation). Validation errors are mapped by `GlobalExceptionHandler` to `400` with `{"error":"VALIDATION_ERROR"}`.
27
+
- Documentation updates for profile usage, CORS, cookies, and deployment notes (Render/Neon).
28
+
29
+
### Fixed
30
+
- Session pruning ClassCastException by replacing derived delete with explicit JPQL bulk delete method and using `@Transactional` in pruner.
31
+
- Added Flyway migration `V4__add_timezone_to_users.sql` to align schema with `UserEntity.timezone`, resolving startup error `column ... timezone does not exist`.
32
+
- Addressed IDE warnings for the GitHub Release step by pinning the action and passing the `files` input; pipeline runs green on tags.
33
+
34
+
---
35
+
36
+
## [v0.1.0] - 2025-10-05 – Initial release
37
+
### Added
38
+
39
+
40
+
### Changed
41
+
42
+
43
+
### Fixed
44
+
45
+
46
+
---
47
+
Reference: See `docs/weekly-plan/week-3/week-3-checkout-backend.md` for a narrative weekly summary.
| WK3-004 | Migration Test in CI | Ensure migration test runs in CI using Testcontainers/Postgres | P1 | Document in instructions.md |
99
-
| WK3-005 | Unit Test Coverage | Add/improve unit tests for UserService, SessionService, password validator (≥75%) | P1 | Document coverage status |
100
-
| WK3-006 | Docs: instructions.md, RISKS.md | Create and link instructions.md and RISKS.md | P1 | Link from README and project board |
101
-
| WK3-007 | JWT Spike Doc | Prepare JWT spike decision doc (pros/cons, migration plan) | P2 | Link from README and project board |
100
+
| WK3-004 | Migration Test in CI | Ensure migration test runs in CI using Testcontainers/Postgres | P1 | Deferred under BACKEND_CI_GUARD; evaluate adding profile/matrix next week |
101
+
| WK3-005 | Unit Test Coverage | Add/improve unit tests for UserService, SessionService, password validator (≥75%) | P1 | Current gate 70% passing; raise to 75% after adding tests |
This document lists current risks in the backend and how we plan to mitigate them. It’s a living file; update as features evolve.
4
+
5
+
## Authentication & Session Management
6
+
- In-memory rate limiting
7
+
- Risk: Rate limiter state is reset on application restart (risk of brute force during a restart) and can produce false positives behind NAT/shared IPs.
8
+
- Mitigation: Threshold set conservatively (5 attempts/5 min). Consider moving to a distributed store (Redis) with IP + device fingerprinting for multi-instance environments. Add allowlist for known CI test users/domains.
9
+
10
+
- Session pruning schedule
11
+
- Risk: If pruning job lags or fails, expired sessions could persist longer than intended, slightly increasing DB footprint.
12
+
- Mitigation: Pruner runs hourly with transactional bulk delete. Expiry is also enforced at request time, so stale rows don’t grant access.
13
+
14
+
- Cookie security
15
+
- Risk: Misconfiguration of cookie domain/flags can expose sessions to subdomains or non-TLS contexts.
16
+
- Mitigation: Properties-driven; `Secure` and proper domain only in `prod`. CORS is strict to the SPA origin.
17
+
18
+
## Input Validation & Error Handling
19
+
- Password complexity
20
+
- Risk: Too lax passwords increase account takeover risk.
21
+
- Mitigation: Enforced via Bean Validation (min 8, includes upper/lower/digit). Consider adding symbol requirement and breached password checks in future.
22
+
23
+
- Error envelope
24
+
- Risk: Overly detailed errors leak information.
25
+
- Mitigation: Centralized error envelope; `BAD_CREDENTIALS` is generic. Continue to avoid echoing sensitive inputs.
26
+
27
+
## Data & Migrations
28
+
- Flyway immutability
29
+
- Risk: Editing applied migrations causes drift.
30
+
- Mitigation: Guard scripts + CI gate. Always add new migrations.
31
+
32
+
- Test vs. Prod DB behavior
33
+
- Risk: H2 and Postgres have subtle differences.
34
+
- Mitigation: Keep JPQL portable; use Testcontainers profile for schema verification.
0 commit comments