@@ -105,10 +105,15 @@ def __init__(
105105 token : Optional [str ] = None ,
106106 client : Optional [AsyncWebClient ] = None ,
107107 # for multi-workspace apps
108+ authorize : Optional [Callable [..., Awaitable [AuthorizeResult ]]] = None ,
108109 installation_store : Optional [AsyncInstallationStore ] = None ,
109110 # for either only bot scope usage or v1.0.x compatibility
110111 installation_store_bot_only : Optional [bool ] = None ,
111- authorize : Optional [Callable [..., Awaitable [AuthorizeResult ]]] = None ,
112+ # for customizing the built-in middleware
113+ request_verification_enabled : bool = True ,
114+ ignoring_self_events_enabled : bool = True ,
115+ ssl_check_enabled : bool = True ,
116+ url_verification_enabled : bool = True ,
112117 # for the OAuth flow
113118 oauth_settings : Optional [AsyncOAuthSettings ] = None ,
114119 oauth_flow : Optional [AsyncOAuthFlow ] = None ,
@@ -155,6 +160,21 @@ async def message_hello(message, say): # async function
155160 by checking if there is a team/user in the installation data.
156161 installation_store: The module offering save/find operations of installation data
157162 installation_store_bot_only: Use `AsyncInstallationStore#async_find_bot()` if True (Default: False)
163+ request_verification_enabled: False if you would like to disable the built-in middleware (Default: True).
164+ `AsyncRequestVerification` is a built-in middleware that verifies the signature in HTTP Mode requests.
165+ Make sure if it's safe enough when you turn a built-in middleware off.
166+ We strongly recommend using RequestVerification for better security.
167+ If you have a proxy that verifies request signature in front of the Bolt app,
168+ it's totally fine to disable RequestVerification to avoid duplication of work.
169+ Don't turn it off just for easiness of development.
170+ ignoring_self_events_enabled: False if you would like to disable the built-in middleware (Default: True).
171+ `AsyncIgnoringSelfEvents` is a built-in middleware that enables Bolt apps to easily skip the events
172+ generated by this app's bot user (this is useful for avoiding code error causing an infinite loop).
173+ url_verification_enabled: False if you would like to disable the built-in middleware (Default: True).
174+ `AsyncUrlVerification` is a built-in middleware that handles url_verification requests
175+ that verify the endpoint for Events API in HTTP Mode requests.
176+ ssl_check_enabled: bool = False if you would like to disable the built-in middleware (Default: True).
177+ `AsyncSslCheck` is a built-in middleware that handles ssl_check requests from Slack.
158178 oauth_settings: The settings related to Slack app installation flow (OAuth flow)
159179 oauth_flow: Instantiated `slack_bolt.oauth.AsyncOAuthFlow`. This is always prioritized over oauth_settings.
160180 verification_token: Deprecated verification mechanism. This can used only for ssl_check requests.
@@ -316,19 +336,33 @@ async def message_hello(message, say): # async function
316336 )
317337
318338 self ._init_middleware_list_done = False
319- self ._init_async_middleware_list ()
339+ self ._init_async_middleware_list (
340+ request_verification_enabled = request_verification_enabled ,
341+ ignoring_self_events_enabled = ignoring_self_events_enabled ,
342+ ssl_check_enabled = ssl_check_enabled ,
343+ url_verification_enabled = url_verification_enabled ,
344+ )
320345
321346 self ._server : Optional [AsyncSlackAppServer ] = None
322347
323- def _init_async_middleware_list (self ):
348+ def _init_async_middleware_list (
349+ self ,
350+ request_verification_enabled : bool = True ,
351+ ignoring_self_events_enabled : bool = True ,
352+ ssl_check_enabled : bool = True ,
353+ url_verification_enabled : bool = True ,
354+ ):
324355 if self ._init_middleware_list_done :
325356 return
326- self ._async_middleware_list .append (
327- AsyncSslCheck (verification_token = self ._verification_token )
328- )
329- self ._async_middleware_list .append (
330- AsyncRequestVerification (self ._signing_secret )
331- )
357+ if ssl_check_enabled is True :
358+ self ._async_middleware_list .append (
359+ AsyncSslCheck (verification_token = self ._verification_token )
360+ )
361+ if request_verification_enabled is True :
362+ self ._async_middleware_list .append (
363+ AsyncRequestVerification (self ._signing_secret )
364+ )
365+ # As authorize is required for making a Bolt app function, we don't offer the flag to disable this
332366 if self ._async_oauth_flow is None :
333367 if self ._token :
334368 self ._async_middleware_list .append (AsyncSingleTeamAuthorization ())
@@ -343,8 +377,10 @@ def _init_async_middleware_list(self):
343377 AsyncMultiTeamsAuthorization (authorize = self ._async_authorize )
344378 )
345379
346- self ._async_middleware_list .append (AsyncIgnoringSelfEvents ())
347- self ._async_middleware_list .append (AsyncUrlVerification ())
380+ if ignoring_self_events_enabled is True :
381+ self ._async_middleware_list .append (AsyncIgnoringSelfEvents ())
382+ if url_verification_enabled is True :
383+ self ._async_middleware_list .append (AsyncUrlVerification ())
348384 self ._init_middleware_list_done = True
349385
350386 # -------------------------
0 commit comments