Learn — Essential security, data, concurrency, and test concepts
Core time: about 7 minutes.
1. Authentication is not authorization
Authentication establishes who the caller is. Authorization establishes whether that caller may perform this action. A logged-in user is not automatically a volunteer coordinator. Review both the route control and tests for an anonymous caller, a wrong-role caller, and an allowed caller.
2. Validation is not parameterization
Validation checks whether input has the required shape and meaning. Parameterized data access keeps input as data rather than executable query text. A syntactically valid email can still contain characters that make string-built SQL unsafe. Use both controls for their different jobs.
3. Confidential data should be minimized
Logs persist and are often widely searchable. Authorization headers may contain bearer tokens; full emails are identifying data. Remove credentials entirely and use only approved, necessary event fields. Never paste a real token into review evidence.
4. Business invariants belong at an authoritative boundary
An invariant is a condition that must remain true, such as “registrations never exceed capacity” or “event and email are unique.” A database constraint or atomic operation protects the invariant across every request path. An application-level “check, then write” sequence can race.
5. Two correct-looking requests can be wrong together
| Time | Request A | Request B |
|---|---|---|
| 1 | Reads count 9 of 10 | — |
| 2 | — | Reads count 9 of 10 |
| 3 | Passes “space remains” check | Passes the same check |
| 4 | Writes registration 10 | Writes registration 11 |
Changing <= to < fixes one boundary error but not this interleaving. The check and state change must be protected as one authoritative operation.
6. Response codes are part of the interface
If the contract says created is 201, invalid is 400, unauthorized is 403, and conflict is 409, returning 200 for every path hides the outcome from callers. Treat exact statuses as testable behavior.
7. Coverage numbers do not replace requirement evidence
A useful test set traces to requirements and includes boundaries, rejection paths, and concurrency where relevant. One happy-path assertion can pass while authorization, validation, capacity, duplicates, logging, and response behavior remain unproved.
Three quick checks with feedback
- Valid email plus string-built SQL: still unsafe; parameterize the query.
- Change
<=to<: fixes the boundary but not the concurrent race. - User is logged in: authentication alone does not prove the coordinator role.
Page summary
These controls are complementary. Next, watch them applied to a smaller diff before you review NeighborLink independently.