Koa Authentication and Authorization
Question Variations
- "Where should an authenticated principal be stored in Koa?"
- "Why is decoding a JWT not authentication?"
- "How would you enforce ownership of a Koa resource route?"
Why This Is Asked
Security middleware shows whether a candidate distinguishes verifying identity from authorizing a specific action. Koa’s ctx.state makes this separation especially visible.
Key Concepts
- Authentication verifies credentials and stores a trusted principal in
ctx.state. - Authorization checks the principal against the requested action and resource.
- Tokens require signature and claim validation before their data is trusted.
- Missing or invalid credentials should fail closed before protected handlers run.
Question Variations
- “Where should an authenticated principal be stored in Koa?”
- “Why is decoding a JWT not authentication?”
- “How would you enforce ownership of a Koa resource route?”