@@ -19,19 +19,12 @@ class AsyncMultiTeamsAuthorization(AsyncAuthorization):
1919 installation_store : AsyncInstallationStore
2020 verification_enabled : bool
2121
22- def __init__ (
23- self ,
24- installation_store : AsyncInstallationStore ,
25- verification_enabled : bool = True ,
26- ):
22+ def __init__ (self , installation_store : AsyncInstallationStore ):
2723 """Multi-workspace authorization.
2824
2925 :param installation_store: The module offering find/save operations of installation data.
30- :param verification_enabled:
31- Calls auth.test for every single incoming request from Slack if True (Default: True)
3226 """
3327 self .installation_store = installation_store
34- self .verification_enabled = verification_enabled
3528 self .logger = get_bolt_logger (AsyncMultiTeamsAuthorization )
3629
3730 async def async_process (
@@ -50,36 +43,23 @@ async def async_process(
5043 if bot is None :
5144 return _build_error_response ()
5245
53- if self .verification_enabled :
54- auth_result = await req .context .client .auth_test (token = bot .bot_token )
55- if auth_result :
56- req .context ["authorization_result" ] = AuthorizationResult (
57- enterprise_id = auth_result .get ("enterprise_id" , None ),
58- team_id = auth_result .get ("team_id" , None ),
59- bot_user_id = auth_result .get ("user_id" , None ),
60- bot_id = auth_result .get ("bot_id" , None ),
61- bot_token = bot .bot_token ,
62- )
63- # TODO: bot -> user token
64- req .context ["token" ] = bot .bot_token
65- req .context ["client" ] = create_async_web_client (bot .bot_token )
66- return await next ()
67- else :
68- # Just in case
69- self .logger .error ("auth.test API call result is unexpectedly None" )
70- return _build_error_response ()
71- else :
46+ auth_result = await req .context .client .auth_test (token = bot .bot_token )
47+ if auth_result :
7248 req .context ["authorization_result" ] = AuthorizationResult (
73- enterprise_id = bot . enterprise_id ,
74- team_id = bot . team_id ,
75- bot_user_id = bot . bot_user_id ,
76- bot_id = bot . bot_id ,
49+ enterprise_id = auth_result . get ( " enterprise_id" , None ) ,
50+ team_id = auth_result . get ( " team_id" , None ) ,
51+ bot_user_id = auth_result . get ( "user_id" , None ) ,
52+ bot_id = auth_result . get ( " bot_id" , None ) ,
7753 bot_token = bot .bot_token ,
7854 )
7955 # TODO: bot -> user token
8056 req .context ["token" ] = bot .bot_token
8157 req .context ["client" ] = create_async_web_client (bot .bot_token )
8258 return await next ()
59+ else :
60+ # Just in case
61+ self .logger .error ("auth.test API call result is unexpectedly None" )
62+ return _build_error_response ()
8363
8464 except SlackApiError as e :
8565 self .logger .error (f"Failed to authorize with the given token ({ e } )" )
0 commit comments