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 servlet
UserAdminServlet
that uses the UserAdmin
class to support the following REST request
(see also OpenAPI Definition):
POST /api/users
registers a new user
-
Implement the servlet filter
AuthenticationFilter
that checks if each request contains an Authorization
header with a valid username and password and adds the authenticated user to the request.
-
Remove the global todo list from the servlet
TodoListServlet
and use the todo list of the authenticated user stored in the request instead.
-
(Optional) Implement the servlet filter
MediaTypeFilter
that immediately returns an error response, if the header Content-Type
or Accept
contains an invalid value.
-
Use the Postman application to test the REST service manually.
-
Run the TodoIntegrationTest to test the REST service automatically.
Solution