yifan-c commented on code in PR #318:
URL: https://github.com/apache/cassandra-sidecar/pull/318#discussion_r2843630085


##########
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:
   For the lifecycle and utilities modules, the pluggability is implemented via 
overriding the Guice provider. Imagining in the internal-sidecar fork, you have 
a internal module that provides a different `LifecycleProvider`. 
   
   So, you are right to call it out. The alternative is to update 
`cqlAuthProvider` to be `@Provides`



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