class_docstr: Slack input channel implementation. Based on the HTTPInputChannel.
class_docstr_tok: ["Slack","input","channel","implementation",".","Based","on","the","HTTPInputChannel","."]
docstr: Validate a request from Slack for its authenticity.
  
  Checks if the signature matches the one we expect from Slack. Ensures
  we don't process request from a third-party disguising as slack.
  
  Args:
      request: incoming request to be checked
  
  Returns:
      `True` if the request came from Slack.
docstr_tok: ["Validate","a","request","from","Slack","for","its","authenticity",".","Checks","if","the","signature","matches","the","one","we","expect","from","Slack",".","Ensures","we","do","n't","process","request","from","a","third-party","disguising","as","slack",".","Args",":","request",":","incoming","request","to","be","checked","Returns",":","`","True","`","if","the","request","came","from","Slack","."]
code: def is_request_from_slack_authentic(self, request: Request) -> bool:
      """Validate a request from Slack for its authenticity.
  
      Checks if the signature matches the one we expect from Slack. Ensures
      we don't process request from a third-party disguising as slack.
  
      Args:
          request: incoming request to be checked
  
      Returns:
          `True` if the request came from Slack.
      """
      try:
          slack_signing_secret = bytes(
              self.slack_signing_secret, "utf-8"
          )
  
          slack_signature = request.headers.get("X-Slack-Signature", "")
          slack_request_timestamp = request.headers.get(
              "X-Slack-Request-Timestamp", "0"
          )
  
          if abs(time.time() - int(slack_request_timestamp)) > 60 * 5:
              # The request timestamp is more than five minutes from local time.
              # It could be a replay attack, so let's ignore it.
              return False
  
          prefix = f"v0:{slack_request_timestamp}:".encode("utf-8")
          basestring = prefix + request.body
          digest = hmac.new(
              slack_signing_secret, basestring, hashlib.sha256
          ).hexdigest()
          computed_signature = f"v0={digest}"
  
          return hmac.compare_digest(
              computed_signature, slack_signature
          )
      except Exception as e:
          logger.error(
              f"Failed to validate slack request authenticity. "
              f"Assuming invalid request. Error: {e}"
          )
          return False
  
imports: import asyncio
  import hashlib
  import hmac
  from http import HTTPStatus
  import json
  import logging
  import re
  import time
  from typing import Any, Awaitable, Callable, Dict, List, Optional, Set, Text
  from rasa.core.channels.channel import InputChannel, OutputChannel, UserMessage
  from rasa.shared.constants import DOCS_URL_CONNECTORS_SLACK
  from rasa.shared.exceptions import InvalidConfigException
  import rasa.shared.utils.io
  from sanic import Blueprint, response
  from sanic.request import Request
  from sanic.response import HTTPResponse
  from slack_sdk.web.async_client import AsyncWebClient
label_desc: Use image node_id 12 for calling the SlackInput obj's underlying member method code with example usage: obj.is_request_from_slack_authentic(request) and returns: hmac, False, False