@@ -140,7 +140,10 @@ async def __call__(self, *args: Any, **kwargs: Any) -> str:
140
140
141
141
# check if any auth services need to be specified yet
142
142
if len (self .__required_authn_params ) > 0 :
143
- req_auth_services = set (l for l in self .__required_authn_params .keys ())
143
+ # Gather all the required auth services into a set
144
+ req_auth_services = set ()
145
+ for s in self .__required_authn_params .values ():
146
+ req_auth_services .update (s )
144
147
raise Exception (
145
148
f"One or more of the following authn services are required to invoke this tool: { ',' .join (req_auth_services )} "
146
149
)
@@ -184,10 +187,12 @@ def add_auth_token_getters(
184
187
"""
185
188
186
189
# throw an error if the authentication source is already registered
187
- dupes = auth_token_getters .keys () & self .__auth_service_token_getters .keys ()
188
- if dupes :
190
+ existing_services = self .__auth_service_token_getters .keys ()
191
+ incoming_services = auth_token_getters .keys ()
192
+ duplicates = existing_services & incoming_services
193
+ if duplicates :
189
194
raise ValueError (
190
- f"Authentication source(s) `{ ', ' .join (dupes )} ` already registered in tool `{ self .__name__ } `."
195
+ f"Authentication source(s) `{ ', ' .join (duplicates )} ` already registered in tool `{ self .__name__ } `."
191
196
)
192
197
193
198
# create a read-only updated value for new_getters
@@ -196,7 +201,7 @@ def add_auth_token_getters(
196
201
)
197
202
# create a read-only updated for params that are still required
198
203
new_req_authn_params = types .MappingProxyType (
199
- filter_required_authn_params (
204
+ identify_required_authn_params (
200
205
self .__required_authn_params , auth_token_getters .keys ()
201
206
)
202
207
)
@@ -207,12 +212,12 @@ def add_auth_token_getters(
207
212
)
208
213
209
214
210
- def filter_required_authn_params (
215
+ def identify_required_authn_params (
211
216
req_authn_params : Mapping [str , list [str ]], auth_service_names : Iterable [str ]
212
217
) -> dict [str , list [str ]]:
213
218
"""
214
- Utility function for reducing 'req_authn_params' to a subset of parameters that
215
- aren't supplied by at least one service in auth_services .
219
+ Identifies authentication parameters that are still required; or not covered by
220
+ the provided `auth_service_names` .
216
221
217
222
Args:
218
223
req_authn_params: A mapping of parameter names to sets of required
0 commit comments