Practical Exercise 3
Hands-On
Add user authentication to an existing Todo API
2026 WayUp
Add authentication to an existing codebase
Extend the vision document to include authentication requirements.
Map user journeys for authentication features.
Signup → Validate → Hash → Store → Token
Credentials → Verify → Generate JWT → Return
Request + Token → Validate → Allow/Deny
Duplicate email, weak password, expired token
Create task epics for the authentication feature.
| Epic | Size | Dependencies |
|---|---|---|
| 1. User Model & Migration | S | Existing DB |
| 2. Password Hashing Utility | S | None |
| 3. User Registration Endpoint | M | 1, 2 |
| 4. JWT Token Generation | M | None |
| 5. Login Endpoint | M | 1, 2, 4 |
| 6. Auth Middleware | M | 4 |
| 7. Associate Todos with Users | M | 1, 6 |
| 8. Protect Todo Endpoints | M | 6, 7 |
Have AI review the authentication plan for security issues.
- Weak password allowed
- No rate limiting
- Token in URL params
- Plain text logging
- Min 8 chars + complexity
- Login attempt limits
- Bearer token in header
- Sanitize log output
Implement user registration with TDD, one criterion at a time.
Create authentication middleware with TDD.
Create a helper function to generate valid test tokens. Mock the JWT verification for unit tests.
Update existing Todo endpoints to require authentication.
GET /todos # Returns ALL todos
GET /todos Authorization: Bearer <jwt> # Returns user's todos only
Create end-to-end tests for the complete auth flow.
How did AIDD help when adding features to an existing codebase?
What security issues did the review phase catch? Would you have found them otherwise?
How did existing tests guide the refactoring? Did any break unexpectedly?
Where did AI struggle with security-sensitive code? How did you verify correctness?
Complex Feature Implementation
You've mastered adding features with AIDD!
2026 WayUp - way-up.io