burmanm commented on code in PR #318:
URL: https://github.com/apache/cassandra-sidecar/pull/318#discussion_r2840042954


##########
server/src/main/java/org/apache/cassandra/sidecar/modules/ConfigurationModule.java:
##########
@@ -121,11 +128,45 @@ CQLSessionProvider cqlSessionProvider(Vertx vertx,
     {
         CQLSessionProviderImpl cqlSessionProvider = new 
CQLSessionProviderImpl(sidecarConfiguration,
                                                                                
NettyOptions.DEFAULT_INSTANCE,
+                                                                               
cqlAuthProvider(sidecarConfiguration),
                                                                                
driverUtils);
         vertx.eventBus().localConsumer(ON_SERVER_STOP.address(), message -> 
cqlSessionProvider.close());
         return cqlSessionProvider;
     }
 
+    CqlAuthProvider cqlAuthProvider(SidecarConfiguration sidecarConfiguration)
+    {
+        DriverConfiguration driverConfiguration = 
sidecarConfiguration.driverConfiguration();
+
+        ParameterizedClassConfiguration config = 
driverConfiguration.authProvider();
+        if (config == null)
+        {
+          // Fallback to the old one
+          String username = driverConfiguration.username() != null ? 
driverConfiguration.username() : "";
+          String password = driverConfiguration.password() != null ? 
driverConfiguration.password() : "";
+
+          return new ConfigProvider(
+                Map.of("username", username, "password", password));
+        }
+
+        if (config.namedParameters() == null)
+        {
+            throw new ConfigurationException("Missing parameters for 
auth_provider");
+        }
+
+        Map<String, String> namedParameters = config.namedParameters();
+
+        if 
(config.className().equalsIgnoreCase(ConfigProvider.class.getName()))
+        {
+            return new ConfigProvider(namedParameters);
+        }
+        if (config.className().equalsIgnoreCase(FileProvider.class.getName()))
+        {
+            return new FileProvider(namedParameters);
+        }
+        throw new ConfigurationException("Unrecognized cql auth_provider " + 
config.className() + " set");

Review Comment:
   I was aware of that (mentioned in the JIRA ticket), but this is not how the 
rest of the project has done it so I modified this one to be the same. 
   
   
https://github.com/apache/cassandra-sidecar/blob/trunk/server/src/main/java/org/apache/cassandra/sidecar/modules/LifecycleModule.java#L79
   
   
https://github.com/apache/cassandra-sidecar/blob/trunk/server/src/main/java/org/apache/cassandra/sidecar/modules/UtilitiesModule.java#L110
   
   Should all these cases also use ClassLoader? It feels a bit out of context 
for this PR.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to