code: def requires_auth(f):
      
      @wraps(f)
  
      def decorated(self, *args, **kwargs):
          """
          """
  
          # Fetch auth options from args
          auth_options = {}
          nipap_args = {}
  
          # validate function arguments
          if len(args) == 1:
              nipap_args = args[0]
          else:
              self.logger.debug("Malformed request: got %d parameters" % len(args))
              raise Fault(1000, ("NIPAP API functions take exactly 1 argument (%d given)") % len(args))
  
          if type(nipap_args) != dict:
              self.logger.debug("Function argument is not struct")
              raise Fault(1000, ("Function argument must be XML-RPC struct/Python dict (Python %s given)." %
                  type(nipap_args).__name__ ))
  
          # fetch auth options
          try:
              auth_options = nipap_args['auth']
              if type(auth_options) is not dict:
                  raise ValueError()
          except (KeyError, ValueError):
              self.logger.debug("Missing/invalid authentication options in request.")
              raise Fault(1000, ("Missing/invalid authentication options in request."))
  
          # fetch authoritative source
          try:
              auth_source = auth_options['authoritative_source']
          except KeyError:
              self.logger.debug("Missing authoritative source in auth options.")
              raise Fault(1000, ("Missing authoritative source in auth options."))
  
          if not request.authorization:
              return authenticate()
  
          # init AuthFacory()
          af = AuthFactory()
          auth = af.get_auth(request.authorization.username,
                  request.authorization.password, auth_source, auth_options or {})
  
          # authenticated?
          if not auth.authenticate():
              self.logger.debug("Incorrect username or password.")
              raise Fault(1510, ("Incorrect username or password."))
  
          # Replace auth options in API call arguments with auth object
          new_args = dict(args[0])
          new_args['auth'] = auth
  
          return f(self, *(new_args,), **kwargs)
  
      return decorated
docs: Class decorator for XML-RPC functions that requires auth