Skip to content

Commit f52b7ff

Browse files
committed
version 1.17.0
1 parent c15141e commit f52b7ff

28 files changed

+1308
-155
lines changed

docs/api-docs/slack_bolt/adapter/aws_lambda/lambda_s3_oauth_flow.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ <h1 class="title">Module <code>slack_bolt.adapter.aws_lambda.lambda_s3_oauth_flo
8787
client_secret=settings.client_secret,
8888
installation_store=settings.installation_store,
8989
bot_only=settings.installation_store_bot_only,
90+
user_token_resolution=(settings.user_token_resolution if settings is not None else &#34;authed_user&#34;),
9091
)
9192

9293
OAuthFlow.__init__(self, client=client, logger=logger, settings=settings)
@@ -176,6 +177,7 @@ <h2 id="args">Args</h2>
176177
client_secret=settings.client_secret,
177178
installation_store=settings.installation_store,
178179
bot_only=settings.installation_store_bot_only,
180+
user_token_resolution=(settings.user_token_resolution if settings is not None else &#34;authed_user&#34;),
179181
)
180182

181183
OAuthFlow.__init__(self, client=client, logger=logger, settings=settings)

docs/api-docs/slack_bolt/app/app.html

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ <h1 class="title">Module <code>slack_bolt.app.app</code></h1>
129129
token_verification_enabled: bool = True,
130130
client: Optional[WebClient] = None,
131131
# for multi-workspace apps
132+
before_authorize: Optional[Union[Middleware, Callable[..., Any]]] = None,
132133
authorize: Optional[Callable[..., AuthorizeResult]] = None,
133134
installation_store: Optional[InstallationStore] = None,
134135
# for either only bot scope usage or v1.0.x compatibility
@@ -183,6 +184,7 @@ <h1 class="title">Module <code>slack_bolt.app.app</code></h1>
183184
token: The bot/user access token required only for single-workspace app.
184185
token_verification_enabled: Verifies the validity of the given token if True.
185186
client: The singleton `slack_sdk.WebClient` instance for this app.
187+
before_authorize: A global middleware that can be executed right before authorize function
186188
authorize: The function to authorize an incoming request from Slack
187189
by checking if there is a team/user in the installation data.
188190
installation_store: The module offering save/find operations of installation data
@@ -243,6 +245,17 @@ <h1 class="title">Module <code>slack_bolt.app.app</code></h1>
243245
# Authorize &amp; OAuthFlow initialization
244246
# --------------------------------------
245247

248+
self._before_authorize: Optional[Middleware] = None
249+
if before_authorize is not None:
250+
if isinstance(before_authorize, Callable):
251+
self._before_authorize = CustomMiddleware(
252+
app_name=self._name,
253+
func=before_authorize,
254+
base_logger=self._framework_logger,
255+
)
256+
elif isinstance(before_authorize, Middleware):
257+
self._before_authorize = before_authorize
258+
246259
self._authorize: Optional[Authorize] = None
247260
if authorize is not None:
248261
if isinstance(authorize, Authorize):
@@ -266,6 +279,7 @@ <h1 class="title">Module <code>slack_bolt.app.app</code></h1>
266279
logger=self._framework_logger,
267280
bot_only=installation_store_bot_only,
268281
client=self._client, # for proxy use cases etc.
282+
user_token_resolution=(settings.user_token_resolution if settings is not None else &#34;authed_user&#34;),
269283
)
270284

271285
self._oauth_flow: Optional[OAuthFlow] = None
@@ -384,6 +398,9 @@ <h1 class="title">Module <code>slack_bolt.app.app</code></h1>
384398
if request_verification_enabled is True:
385399
self._middleware_list.append(RequestVerification(self._signing_secret, base_logger=self._base_logger))
386400

401+
if self._before_authorize is not None:
402+
self._middleware_list.append(self._before_authorize)
403+
387404
# As authorize is required for making a Bolt app function, we don&#39;t offer the flag to disable this
388405
if self._oauth_flow is None:
389406
if self._token is not None:
@@ -407,7 +424,13 @@ <h1 class="title">Module <code>slack_bolt.app.app</code></h1>
407424
else:
408425
raise BoltError(error_token_required())
409426
else:
410-
self._middleware_list.append(MultiTeamsAuthorization(authorize=self._authorize, base_logger=self._base_logger))
427+
self._middleware_list.append(
428+
MultiTeamsAuthorization(
429+
authorize=self._authorize,
430+
base_logger=self._base_logger,
431+
user_token_resolution=self._oauth_flow.settings.user_token_resolution,
432+
)
433+
)
411434
if ignoring_self_events_enabled is True:
412435
self._middleware_list.append(IgnoringSelfEvents(base_logger=self._base_logger))
413436
if url_verification_enabled is True:
@@ -1456,7 +1479,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
14561479
<dl>
14571480
<dt id="slack_bolt.app.app.App"><code class="flex name class">
14581481
<span>class <span class="ident">App</span></span>
1459-
<span>(</span><span>*, logger: Optional[logging.Logger] = None, name: Optional[str] = None, process_before_response: bool = False, raise_error_for_unhandled_request: bool = False, signing_secret: Optional[str] = None, token: Optional[str] = None, token_verification_enabled: bool = True, client: Optional[slack_sdk.web.client.WebClient] = None, authorize: Optional[Callable[..., <a title="slack_bolt.authorization.authorize_result.AuthorizeResult" href="../authorization/authorize_result.html#slack_bolt.authorization.authorize_result.AuthorizeResult">AuthorizeResult</a>]] = None, installation_store: Optional[slack_sdk.oauth.installation_store.installation_store.InstallationStore] = None, installation_store_bot_only: Optional[bool] = None, request_verification_enabled: bool = True, ignoring_self_events_enabled: bool = True, ssl_check_enabled: bool = True, url_verification_enabled: bool = True, oauth_settings: Optional[<a title="slack_bolt.oauth.oauth_settings.OAuthSettings" href="../oauth/oauth_settings.html#slack_bolt.oauth.oauth_settings.OAuthSettings">OAuthSettings</a>] = None, oauth_flow: Optional[<a title="slack_bolt.oauth.oauth_flow.OAuthFlow" href="../oauth/oauth_flow.html#slack_bolt.oauth.oauth_flow.OAuthFlow">OAuthFlow</a>] = None, verification_token: Optional[str] = None, listener_executor: Optional[concurrent.futures._base.Executor] = None)</span>
1482+
<span>(</span><span>*, logger: Optional[logging.Logger] = None, name: Optional[str] = None, process_before_response: bool = False, raise_error_for_unhandled_request: bool = False, signing_secret: Optional[str] = None, token: Optional[str] = None, token_verification_enabled: bool = True, client: Optional[slack_sdk.web.client.WebClient] = None, before_authorize: Union[<a title="slack_bolt.middleware.middleware.Middleware" href="../middleware/middleware.html#slack_bolt.middleware.middleware.Middleware">Middleware</a>, Callable[..., Any], ForwardRef(None)] = None, authorize: Optional[Callable[..., <a title="slack_bolt.authorization.authorize_result.AuthorizeResult" href="../authorization/authorize_result.html#slack_bolt.authorization.authorize_result.AuthorizeResult">AuthorizeResult</a>]] = None, installation_store: Optional[slack_sdk.oauth.installation_store.installation_store.InstallationStore] = None, installation_store_bot_only: Optional[bool] = None, request_verification_enabled: bool = True, ignoring_self_events_enabled: bool = True, ssl_check_enabled: bool = True, url_verification_enabled: bool = True, oauth_settings: Optional[<a title="slack_bolt.oauth.oauth_settings.OAuthSettings" href="../oauth/oauth_settings.html#slack_bolt.oauth.oauth_settings.OAuthSettings">OAuthSettings</a>] = None, oauth_flow: Optional[<a title="slack_bolt.oauth.oauth_flow.OAuthFlow" href="../oauth/oauth_flow.html#slack_bolt.oauth.oauth_flow.OAuthFlow">OAuthFlow</a>] = None, verification_token: Optional[str] = None, listener_executor: Optional[concurrent.futures._base.Executor] = None)</span>
14601483
</code></dt>
14611484
<dd>
14621485
<div class="desc"><p>Bolt App that provides functionalities to register middleware/listeners.</p>
@@ -1502,6 +1525,8 @@ <h2 id="args">Args</h2>
15021525
<dd>Verifies the validity of the given token if True.</dd>
15031526
<dt><strong><code>client</code></strong></dt>
15041527
<dd>The singleton <code>slack_sdk.WebClient</code> instance for this app.</dd>
1528+
<dt><strong><code>before_authorize</code></strong></dt>
1529+
<dd>A global middleware that can be executed right before authorize function</dd>
15051530
<dt><strong><code>authorize</code></strong></dt>
15061531
<dd>The function to authorize an incoming request from Slack
15071532
by checking if there is a team/user in the installation data.</dd>
@@ -1560,6 +1585,7 @@ <h2 id="args">Args</h2>
15601585
token_verification_enabled: bool = True,
15611586
client: Optional[WebClient] = None,
15621587
# for multi-workspace apps
1588+
before_authorize: Optional[Union[Middleware, Callable[..., Any]]] = None,
15631589
authorize: Optional[Callable[..., AuthorizeResult]] = None,
15641590
installation_store: Optional[InstallationStore] = None,
15651591
# for either only bot scope usage or v1.0.x compatibility
@@ -1614,6 +1640,7 @@ <h2 id="args">Args</h2>
16141640
token: The bot/user access token required only for single-workspace app.
16151641
token_verification_enabled: Verifies the validity of the given token if True.
16161642
client: The singleton `slack_sdk.WebClient` instance for this app.
1643+
before_authorize: A global middleware that can be executed right before authorize function
16171644
authorize: The function to authorize an incoming request from Slack
16181645
by checking if there is a team/user in the installation data.
16191646
installation_store: The module offering save/find operations of installation data
@@ -1674,6 +1701,17 @@ <h2 id="args">Args</h2>
16741701
# Authorize &amp; OAuthFlow initialization
16751702
# --------------------------------------
16761703

1704+
self._before_authorize: Optional[Middleware] = None
1705+
if before_authorize is not None:
1706+
if isinstance(before_authorize, Callable):
1707+
self._before_authorize = CustomMiddleware(
1708+
app_name=self._name,
1709+
func=before_authorize,
1710+
base_logger=self._framework_logger,
1711+
)
1712+
elif isinstance(before_authorize, Middleware):
1713+
self._before_authorize = before_authorize
1714+
16771715
self._authorize: Optional[Authorize] = None
16781716
if authorize is not None:
16791717
if isinstance(authorize, Authorize):
@@ -1697,6 +1735,7 @@ <h2 id="args">Args</h2>
16971735
logger=self._framework_logger,
16981736
bot_only=installation_store_bot_only,
16991737
client=self._client, # for proxy use cases etc.
1738+
user_token_resolution=(settings.user_token_resolution if settings is not None else &#34;authed_user&#34;),
17001739
)
17011740

17021741
self._oauth_flow: Optional[OAuthFlow] = None
@@ -1815,6 +1854,9 @@ <h2 id="args">Args</h2>
18151854
if request_verification_enabled is True:
18161855
self._middleware_list.append(RequestVerification(self._signing_secret, base_logger=self._base_logger))
18171856

1857+
if self._before_authorize is not None:
1858+
self._middleware_list.append(self._before_authorize)
1859+
18181860
# As authorize is required for making a Bolt app function, we don&#39;t offer the flag to disable this
18191861
if self._oauth_flow is None:
18201862
if self._token is not None:
@@ -1838,7 +1880,13 @@ <h2 id="args">Args</h2>
18381880
else:
18391881
raise BoltError(error_token_required())
18401882
else:
1841-
self._middleware_list.append(MultiTeamsAuthorization(authorize=self._authorize, base_logger=self._base_logger))
1883+
self._middleware_list.append(
1884+
MultiTeamsAuthorization(
1885+
authorize=self._authorize,
1886+
base_logger=self._base_logger,
1887+
user_token_resolution=self._oauth_flow.settings.user_token_resolution,
1888+
)
1889+
)
18421890
if ignoring_self_events_enabled is True:
18431891
self._middleware_list.append(IgnoringSelfEvents(base_logger=self._base_logger))
18441892
if url_verification_enabled is True:

0 commit comments

Comments
 (0)