Back to Bolt Python

slack_bolt.middleware.request_verification.async_request_verification API documentation

docs/reference/middleware/request_verification/async_request_verification.html

1.28.02.5 KB
Original Source

Classes

class AsyncRequestVerification (signing_secret: str, base_logger: logging.Logger | None = None)#Expand source code

class AsyncRequestVerification(RequestVerification, AsyncMiddleware):
    """Verifies an incoming request by checking the validity of
    `x-slack-signature`, `x-slack-request-timestamp`, and its body data.

    Refer to https://docs.slack.dev/authentication/verifying-requests-from-slack/ for details.
    """

    async def async_process(
        self,
        *,
        req: AsyncBoltRequest,
        resp: BoltResponse,
        # As this method is not supposed to be invoked by bolt-python users,
        # the naming conflict with the built-in one affects
        # only the internals of this method
        next: Callable[[], Awaitable[BoltResponse]],
    ) -> BoltResponse:
        if self._can_skip(req.mode, req.body):
            return await next()

        body = req.raw_body
        timestamp = req.headers.get("x-slack-request-timestamp", ["0"])[0]
        signature = req.headers.get("x-slack-signature", [""])[0]
        if self.verifier.is_valid(body, timestamp, signature):
            return await next()
        else:
            self._debug_log_error(signature, timestamp, body)
            return self._build_error_response()

Verifies an incoming request by checking the validity of x-slack-signature, x-slack-request-timestamp, and its body data.

Refer to https://docs.slack.dev/authentication/verifying-requests-from-slack/ for details.

Verifies an incoming request by checking the validity of x-slack-signature, x-slack-request-timestamp, and its body data.

Refer to https://docs.slack.dev/authentication/verifying-requests-from-slack/ for details.

Args

signing_secret The signing secret base_logger The base logger

Ancestors

Inherited members

  • RequestVerification:

    • name
    • process
  • AsyncMiddleware:

    • async_process