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

  1. 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).
  2. 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 an error response is returned.
  3. Modify the TodosServlet and the TodoServlet so that they use the todos of the authenticated user stored in the request.
  4. Use the Postman application to test the REST service manually.
  5. Run the TodoRestServiceIT to test the REST service automatically.
  6. (Optional) Implement the AuthServlet that supports the REST request HEAD /api/auth which can be used to solely for authenticating a user.
  7. (Optional) Implement the MediaTypeFilter that immediately returns an error response, if the Accept or Content-Type header contains an invalid value.
Solution