Practice assignment
JWT authentication take-home assignment
- JWT HS256
- Roles
- BCrypt
- Spring or Express
- 3–4 hours
An internal notes service must authenticate users and make sure people only see their own data, while admins can see everything. HireCheck has a Spring Security version and a Node.js/TypeScript version of this task. The HTTP story is the same; the TypeScript one also asks for login lockout and tighter token checks.
The starter
Spring Boot — work in SecurityConfig, AuthController.login and NoteController.mine.
POST /api/auth/login → {token}
GET /api/notes (authenticated, only mine)
GET /api/admin/notes (ADMIN only)
Node.js / TypeScript — work in token issue/verify, auth middleware and the notes service. Login also has a 5-failure / 15-minute lockout and Cache-Control: no-store on the token response.
Requirements
POST /api/auth/loginissues an HS256 JWT withsuband arolesclaim, 15-minute expiry. Wrong password and unknown user share the same401.- Passwords are stored with bcrypt. The signing secret comes from configuration.
- Authenticated users list only their own notes. A missing or bad token is
401; a valid token without the admin role on an admin route is403. - The API is stateless (no session cookie, CSRF off for bearer tokens).
The TypeScript brief additionally pins algorithms: ["HS256"], injects a clock, hides foreign notes behind 404, and rate-limits login.
Grading rubric
| Area | Points |
|---|---|
| Correctness (provided tests) | 30 |
| Authorization (no data leaks; 401 vs 403, and 404 where specified) | 20 |
| Credential handling: bcrypt, no user enumeration, secret config | 15 |
| Own tests (expiry, missing role claim, forged token) | 15 |
| Structure | 5 |
| NOTES.md: refresh tokens, revocation, key rotation, rate limiting | 15 |
Levels: junior ≥ 60, mid ≥ 75, senior ≥ 85 and a strong NOTES.md. The TypeScript rubric splits token handling and lockout slightly differently; the bars are the same.
What reviewers look for
- Identical error bodies for unknown users and wrong passwords.
- Ownership enforced in the query or in one middleware, not “filter after findAll”.
- Algorithm pinning and an injected clock — especially on the Node task.
- NOTES.md that actually discusses refresh tokens, revocation and how lockout works across several instances (Redis, not a process map).
Common mistakes
- Different error messages for “user not found” and “wrong password”.
- Accepting a token's
algat face value, oralg=none. - Putting the JWT secret in source control.
- Returning
403for a note that belongs to someone else, which confirms the id exists. The TypeScript brief wants404in that case. - An in-memory lockout counter presented as production-ready in a multi-instance NOTES.md.
How to run it
Spring Boot: mvn verify. Node.js: npm ci and npm test. Both suites include a hardening test class.
Paste an auth-heavy job posting and generate a Spring or TypeScript practice task.
Generate one from a job adRelated practice tasks
Frequently asked questions
- Should I implement refresh tokens?
- Not unless you have time after the provided tests are green. The brief asks for a 15-minute access token. Refresh tokens, rotation and revocation belong in NOTES.md for a senior grade.
- Spring Security or hand-rolled filters?
- On the Java task, use Spring Security — that is the point of the exercise. On the Node task, a small typed middleware is expected, not a full framework.
- Is a coding challenge about JWT enough without a domain model?
- This one still has a domain: notes and ownership. A take-home that is only 'implement login' is usually weaker practice.
Practice only. This is an original HireCheck practice assignment, not a real employer's take-home, and it is not affiliated with any company mentioned as a role example.