This project is an educational API security lab. It demonstrates how a small Users API can be protected against several common API security mistakes.
The internal user objects contain fields that must not be returned to clients:
databaseIdpasswordHashtokeninternalNotes
The API returns only a public DTO:
idusernamedisplayNameemailrole
A regular user can access only their own profile. Admin users can access all profiles.
Protected endpoints:
GET /users/:userIdPATCH /users/:userId
Only an admin can list all users:
GET /users
Only these fields are accepted in update requests:
displayNameemailpassword
Fields such as role, token, databaseId and internalNotes are rejected.
The demo does not store plaintext passwords. Password values are converted to PBKDF2 hashes before being stored in memory.
This is not a production authentication system. The project uses static demo tokens from environment variables to keep the lab small and easy to run locally.
For production, replace demo tokens with proper authentication and authorization, for example:
- OAuth 2.0 / OpenID Connect;
- signed JWT access tokens;
- secure session management;
- persistent database;
- rate limiting;
- centralized audit logging.