Middleware that provides authentication for REST endpoints.