Practice assignment

JWT authentication take-home assignment

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

  1. POST /api/auth/login issues an HS256 JWT with sub and a roles claim, 15-minute expiry. Wrong password and unknown user share the same 401.
  2. Passwords are stored with bcrypt. The signing secret comes from configuration.
  3. 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 is 403.
  4. 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

AreaPoints
Correctness (provided tests)30
Authorization (no data leaks; 401 vs 403, and 404 where specified)20
Credential handling: bcrypt, no user enumeration, secret config15
Own tests (expiry, missing role claim, forged token)15
Structure5
NOTES.md: refresh tokens, revocation, key rotation, rate limiting15

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

Common mistakes

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 ad

Related 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.