code: def authentication_required(req, resp, resource, uri_kwargs):
      
      if 'user' not in req.context:
          args = ["Unauthorized", "This resource requires authentication"]
  
          # compat: falcon >= 1.0.0 requires the list of challenges
          if FALCON_VERSION >= (1, 0, 0):
              args.append(req.context.get('challenges', []))
  
          raise HTTPUnauthorized(*args)
docs: Ensure that user is authenticated otherwise return ``401 Unauthorized``.
  
      If request fails to authenticate this authorization hook will also
      include list of ``WWW-Athenticate`` challenges.
  
      Args:
          req (falcon.Request): the request object.
          resp (falcon.Response): the response object.
          resource (object): the resource object.
          uri_kwargs (dict): keyword arguments from the URI template.
  
      .. versionadded:: 0.4.0