code: def authenticate(cls, request, route, server_config):
          
          if not server_config.getboolean("auth", False):
              return
  
          user = server_config.get("user", "").strip()
          password = server_config.get("password", "").strip()
  
          if len(user) == 0:
              return
  
          if "AUTHORIZATION" in request.headers:
              if request.headers["AUTHORIZATION"] == aiohttp.helpers.BasicAuth(user, password, "utf-8").encode():
                  return
  
          log.error("Invalid auth. Username should %s", user)
  
          response = Response(request=request, route=route)
          response.set_status(401)
          response.headers["WWW-Authenticate"] = 'Basic realm="GNS3 server"'
          # Force close the keep alive. Work around a Qt issue where Qt timeout instead of handling the 401
          # this happen only for the first query send by the client.
          response.force_close()
          return response
docs: Ask user for authentication
  
          :returns: Response if you need to auth the user otherwise None