File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -203,14 +203,14 @@ impl AuthMechanism {
203
203
MONGODB_OIDC_STR , ENVIRONMENT_PROP_STR
204
204
) ) ) ;
205
205
}
206
+ let has_token_resource = credential
207
+ . mechanism_properties
208
+ . as_ref ( )
209
+ . unwrap_or ( default_document)
210
+ . contains_key ( TOKEN_RESOURCE_PROP_STR ) ;
206
211
match environment {
207
212
Ok ( AZURE_ENVIRONMENT_VALUE_STR ) | Ok ( GCP_ENVIRONMENT_VALUE_STR ) => {
208
- if !credential
209
- . mechanism_properties
210
- . as_ref ( )
211
- . unwrap_or ( default_document)
212
- . contains_key ( TOKEN_RESOURCE_PROP_STR )
213
- {
213
+ if !has_token_resource {
214
214
return Err ( Error :: invalid_argument ( format ! (
215
215
"`{}` must be set for {} authentication in the `{}` or `{}` `{}`" ,
216
216
TOKEN_RESOURCE_PROP_STR ,
@@ -221,7 +221,19 @@ impl AuthMechanism {
221
221
) ) ) ;
222
222
}
223
223
}
224
- _ => ( ) ,
224
+ _ => {
225
+ if has_token_resource {
226
+ return Err ( Error :: invalid_argument ( format ! (
227
+ "`{}` must not be set for {} authentication unless using the `{}` \
228
+ or `{}` `{}`",
229
+ TOKEN_RESOURCE_PROP_STR ,
230
+ MONGODB_OIDC_STR ,
231
+ AZURE_ENVIRONMENT_VALUE_STR ,
232
+ GCP_ENVIRONMENT_VALUE_STR ,
233
+ ENVIRONMENT_PROP_STR ,
234
+ ) ) ) ;
235
+ }
236
+ }
225
237
}
226
238
if credential
227
239
. source
You can’t perform that action at this time.
0 commit comments