Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Endpoints that authenticate but don't authorize
card 2 of 6
Who you are vs. what you may touch
builds on: Trust boundaries and untrusted input, What the agent cannot see
**Authentication** answers *who is calling*. **Authorization** answers *may this caller access this record*. Codebases often enforce the second away from the handler: router middleware, a scoped query helper, a policy class. The agent copies the handler it opened. The guard lived in a file it never read. Its test logs in as the owner, so it's green. Later cost: any logged-in user reads or changes others' data by editing an id.
Terms on this card
- Authentication
- Establishing who the caller is, e.g. by checking a session, token or password.
- Authorization
- Deciding whether this authenticated caller is allowed to read or change this specific record or action.
- middleware
- Code that runs before (or after) a request handler, often attached to a whole group of routes, e.g. to check login or ownership.
- router
- An object grouping routes. Middleware attached where it is mounted applies to every route on it, but not to routes on other routers.
- scoped query helper
- A shared function that always adds the caller's filter (owner or organisation) to database queries, so handlers only see allowed rows.
Lesson goal: Spot new endpoints or queries that check who the caller is but not whether they may access this record (insecure direct object references). Explain why agents copying a nearby handler often miss ownership checks that are enforced elsewhere in the codebase. ·
the whole lesson