valepakh commented on code in PR #2339:
URL: https://github.com/apache/ignite-3/pull/2339#discussion_r1289885261


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/rest/ApiClientFactory.java:
##########
@@ -108,17 +124,20 @@ private ApiClientSettings settings(String path, boolean 
enableBasicAuthenticatio
                 
.trustStorePassword(configManager.getCurrentProperty(REST_TRUST_STORE_PASSWORD.value()));
 
         if (enableBasicAuthentication) {
+            // Use credentials from current session settings if exist
+            ApiClientSettings currentCredentialsSettings = 
currentSessionSettings();
+            String username = currentCredentialsSettings != null
+                    ? currentCredentialsSettings.basicAuthenticationUsername()
+                    : 
configManager.getCurrentProperty(BASIC_AUTHENTICATION_USERNAME.value());
+            String password = currentCredentialsSettings != null
+                    ? currentCredentialsSettings.basicAuthenticationPassword()
+                    : 
configManager.getCurrentProperty(BASIC_AUTHENTICATION_PASSWORD.value());
             builder
-                    
.basicAuthenticationUsername(configManager.getCurrentProperty(BASIC_AUTHENTICATION_USERNAME.value()))
-                    
.basicAuthenticationPassword(configManager.getCurrentProperty(BASIC_AUTHENTICATION_PASSWORD.value()));
+                    .basicAuthenticationUsername(username)
+                    .basicAuthenticationPassword(password);
         }

Review Comment:
   Maybe it would be clearer to extract this to the separate method?
   Right now passing false here and setting username/password later in the 
`getClient(String path, String username, String password)` seems strange.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to