@@ -163,11 +163,10 @@ impl Callback {
163163 let resource = resource. to_string ( ) ;
164164 let client_id = client_id. map ( |s| s. to_string ( ) ) ;
165165 let mut url = format ! (
166- "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource={}" ,
167- resource
166+ "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource={resource}"
168167 ) ;
169168 if let Some ( ref client_id) = client_id {
170- url. push_str ( & format ! ( "&client_id={}" , client_id ) ) ;
169+ url. push_str ( & format ! ( "&client_id={client_id}" ) ) ;
171170 }
172171 Self :: new_function (
173172 move |_| {
@@ -182,7 +181,7 @@ impl Callback {
182181 . map_err ( |e| {
183182 Error :: authentication_error (
184183 MONGODB_OIDC_STR ,
185- & format ! ( "Failed to get access token from Azure IDMS: {}" , e ) ,
184+ & format ! ( "Failed to get access token from Azure IDMS: {e}" ) ,
186185 )
187186 } ) ;
188187 let response = response?;
@@ -191,7 +190,7 @@ impl Callback {
191190 . map_err ( |e| {
192191 Error :: authentication_error (
193192 MONGODB_OIDC_STR ,
194- & format ! ( "Failed to get access token from Azure IDMS: {}" , e ) ,
193+ & format ! ( "Failed to get access token from Azure IDMS: {e}" ) ,
195194 )
196195 } ) ?
197196 . to_string ( ) ;
@@ -200,17 +199,14 @@ impl Callback {
200199 . map_err ( |e| {
201200 Error :: authentication_error (
202201 MONGODB_OIDC_STR ,
203- & format ! ( "Failed to get expires_in from Azure IDMS: {}" , e ) ,
202+ & format ! ( "Failed to get expires_in from Azure IDMS: {e}" ) ,
204203 )
205204 } ) ?
206205 . parse :: < u64 > ( )
207206 . map_err ( |e| {
208207 Error :: authentication_error (
209208 MONGODB_OIDC_STR ,
210- & format ! (
211- "Failed to parse expires_in from Azure IDMS as u64: {}" ,
212- e
213- ) ,
209+ & format ! ( "Failed to parse expires_in from Azure IDMS as u64: {e}" ) ,
214210 )
215211 } ) ?;
216212 let expires = Some ( Instant :: now ( ) + Duration :: from_secs ( expires_in) ) ;
@@ -231,8 +227,7 @@ impl Callback {
231227 fn gcp_callback ( resource : & str ) -> Function {
232228 use futures_util:: FutureExt ;
233229 let url = format ! (
234- "http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience={}" ,
235- resource
230+ "http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience={resource}"
236231 ) ;
237232 Self :: new_function (
238233 move |_| {
@@ -247,7 +242,7 @@ impl Callback {
247242 . map_err ( |e| {
248243 Error :: authentication_error (
249244 MONGODB_OIDC_STR ,
250- & format ! ( "Failed to get access token from GCP IDMS: {}" , e ) ,
245+ & format ! ( "Failed to get access token from GCP IDMS: {e}" ) ,
251246 )
252247 } ) ;
253248 let access_token = response?;
@@ -732,8 +727,7 @@ fn get_allowed_hosts(mechanism_properties: Option<&Document>) -> Result<Vec<&str
732727 . map ( |host| {
733728 host. as_str ( ) . ok_or_else ( || {
734729 auth_error ( format ! (
735- "`{}` must contain only strings" ,
736- ALLOWED_HOSTS_PROP_STR
730+ "`{ALLOWED_HOSTS_PROP_STR}` must contain only strings"
737731 ) )
738732 } )
739733 } )
@@ -928,41 +922,34 @@ pub(super) fn validate_credential(credential: &Credential) -> Result<()> {
928922 for k in properties. keys ( ) {
929923 if VALID_PROPERTIES . iter ( ) . all ( |p| * p != k) {
930924 return Err ( Error :: invalid_argument ( format ! (
931- "'{}' is not a valid property for {} authentication" ,
932- k, MONGODB_OIDC_STR ,
925+ "'{k}' is not a valid property for {MONGODB_OIDC_STR} authentication" ,
933926 ) ) ) ;
934927 }
935928 }
936929 let environment = properties. get_str ( ENVIRONMENT_PROP_STR ) ;
937930 if environment. is_ok ( ) && credential. oidc_callback . is_user_provided ( ) {
938931 return Err ( Error :: invalid_argument ( format ! (
939- "OIDC callback cannot be set for {} authentication, if an `{}` is set" ,
940- MONGODB_OIDC_STR , ENVIRONMENT_PROP_STR
932+ "OIDC callback cannot be set for {MONGODB_OIDC_STR } authentication, if an \
933+ `{ ENVIRONMENT_PROP_STR}` is set"
941934 ) ) ) ;
942935 }
943936 let has_token_resource = properties. contains_key ( TOKEN_RESOURCE_PROP_STR ) ;
944937 match environment {
945938 Ok ( AZURE_ENVIRONMENT_VALUE_STR ) | Ok ( GCP_ENVIRONMENT_VALUE_STR ) => {
946939 if !has_token_resource {
947940 return Err ( Error :: invalid_argument ( format ! (
948- "`{}` must be set for {} authentication in the `{}` or `{}` `{}`" ,
949- TOKEN_RESOURCE_PROP_STR ,
950- MONGODB_OIDC_STR ,
951- AZURE_ENVIRONMENT_VALUE_STR ,
952- GCP_ENVIRONMENT_VALUE_STR ,
953- ENVIRONMENT_PROP_STR ,
941+ "`{TOKEN_RESOURCE_PROP_STR}` must be set for {MONGODB_OIDC_STR} \
942+ authentication in the `{AZURE_ENVIRONMENT_VALUE_STR}` or \
943+ `{GCP_ENVIRONMENT_VALUE_STR}` `{ENVIRONMENT_PROP_STR}`",
954944 ) ) ) ;
955945 }
956946 }
957947 _ => {
958948 if has_token_resource {
959949 return Err ( Error :: invalid_argument ( format ! (
960- "`{}` must not be set for {} authentication unless using the `{}` or `{}` `{}`" ,
961- TOKEN_RESOURCE_PROP_STR ,
962- MONGODB_OIDC_STR ,
963- AZURE_ENVIRONMENT_VALUE_STR ,
964- GCP_ENVIRONMENT_VALUE_STR ,
965- ENVIRONMENT_PROP_STR ,
950+ "`{TOKEN_RESOURCE_PROP_STR}` must not be set for {MONGODB_OIDC_STR} \
951+ authentication unless using the `{AZURE_ENVIRONMENT_VALUE_STR}` or \
952+ `{GCP_ENVIRONMENT_VALUE_STR}` `{ENVIRONMENT_PROP_STR}`",
966953 ) ) ) ;
967954 }
968955 }
@@ -983,27 +970,25 @@ pub(super) fn validate_credential(credential: &Credential) -> Result<()> {
983970 && credential. username . is_some ( )
984971 {
985972 return Err ( Error :: invalid_argument ( format ! (
986- "username must not be set for {} authentication in the {} {}" ,
987- MONGODB_OIDC_STR , TEST_ENVIRONMENT_VALUE_STR , ENVIRONMENT_PROP_STR ,
973+ "username must not be set for {MONGODB_OIDC_STR } authentication in the \
974+ { TEST_ENVIRONMENT_VALUE_STR} { ENVIRONMENT_PROP_STR}" ,
988975 ) ) ) ;
989976 }
990977 if credential. password . is_some ( ) {
991978 return Err ( Error :: invalid_argument ( format ! (
992- "password must not be set for {} authentication" ,
993- MONGODB_OIDC_STR
979+ "password must not be set for {MONGODB_OIDC_STR} authentication"
994980 ) ) ) ;
995981 }
996982 if let Ok ( env) = environment {
997983 if VALID_ENVIRONMENTS . iter ( ) . all ( |e| * e != env) {
998984 return Err ( Error :: invalid_argument ( format ! (
999- "unsupported environment for {} authentication: {}" ,
1000- MONGODB_OIDC_STR , env,
985+ "unsupported environment for {MONGODB_OIDC_STR} authentication: {env}" ,
1001986 ) ) ) ;
1002987 }
1003988 }
1004989 if let Some ( allowed_hosts) = properties. get ( ALLOWED_HOSTS_PROP_STR ) {
1005990 allowed_hosts. as_array ( ) . ok_or_else ( || {
1006- Error :: invalid_argument ( format ! ( "`{}` must be an array" , ALLOWED_HOSTS_PROP_STR ) )
991+ Error :: invalid_argument ( format ! ( "`{ALLOWED_HOSTS_PROP_STR }` must be an array" ) )
1007992 } ) ?;
1008993 }
1009994 Ok ( ( ) )
0 commit comments