class_docstr: Duo base app integration. This is subclassed for the auth and admin APIs
class_docstr_tok: ["Duo","base","app","integration",".","This","is","subclassed","for","the","auth","and","admin","APIs"]
docstr: Duo requests must be signed each time.
  
  This has been largely borrowed/updated from here:
      https://github.com/duosecurity/duo_client_python/blob/master/duo_client/admin.py
docstr_tok: ["Duo","requests","must","be","signed","each","time",".","This","has","been","largely","borrowed\/updated","from","here",":","https",":","\/\/github.com\/duosecurity\/duo_client_python\/blob\/master\/duo_client\/admin.py"]
code: def _generate_auth(self, hostname, params):
      """Duo requests must be signed each time.
  
      This has been largely borrowed/updated from here:
          https://github.com/duosecurity/duo_client_python/blob/master/duo_client/admin.py
      """
      formatted_date = datetime.utcnow().strftime(
          "%a, %d %b %Y %H:%M:%S -0000"
      )
  
      auth_string = "\n".join(
          [
              formatted_date,
              "GET",
              hostname,
              self._endpoint(),
              urllib.parse.urlencode(params),
          ]
      ).encode()
  
      try:
          signature = hmac.new(
              self._config.auth["secret_key"].encode(),
              auth_string,
              hashlib.sha1,
          )
      # Since we force the auth_string and auth['secret_key'] to types which
      # support .encode(), we must expand the catch to include attribute
      # errors for mismatched types.
      except (TypeError, AttributeError):
          LOGGER.exception("Could not generate hmac signature")
          return False
  
      # Format the basic auth with integration key and the hmac hex digest
      basic_auth = ":".join(
          [self._config.auth["integration_key"], signature.hexdigest()]
      ).encode()
  
      return {
          "Date": formatted_date,
          "Authorization": "Basic {}".format(
              b64encode(basic_auth).decode()
          ),
          "Host": hostname,
      }
  
imports: from base64 import b64encode
  from datetime import datetime
  import hashlib
  import hmac
  import re
  import urllib.request
  import urllib.parse
  import urllib.error
  import requests
  from .None import AppIntegration, StreamAlertApp, get_logger
label_desc: Use image node_id 3 for calling the DuoApp obj's underlying member method code with example usage: obj._generate_auth(hostname, params) and returns: dict, False