Web Programming
Todo REST Service (Authentication)
The objective of this exercise is to secure the REST interface of a todo service using basic authentication.
Tasks
-
Implement the
UsersServlet that uses the user service to register a user in response to the REST request POST /api/users
(see also OpenAPI specification).
-
Implement the
AuthenticationFilter that checks if each request related to todos contains a valid Authorization header and authenticates the corresponding user; if successful, the username is added to the request, otherwise the error response 401 (Unauthorized) is returned.
-
Modify the
TodosServlet so that it accesses the todos of the authenticated user.
-
Use the Bruno utility to test the REST service.
-
(Optional) Implement the
AuthServlet that supports the REST request HEAD /api/auth which can be used for authenticating a user.
Solution