Copilot commented on code in PR #10971:
URL: https://github.com/apache/gravitino/pull/10971#discussion_r3212849407


##########
server/src/main/java/org/apache/gravitino/server/GravitinoServer.java:
##########
@@ -123,6 +124,10 @@ public ServerConfig serverConfig() {
   }
 
   private void initializeRestApi() {
+    boolean enableBasicAuthenticator =
+        serverConfig
+            .get(Configs.AUTHENTICATORS)
+            .contains(AuthenticatorType.BASIC.name().toLowerCase());

Review Comment:
   `initializeRestApi()` treats `gravitino.authenticators` containing `basic` 
as the switch to enable the built-in IdP APIs, but the server authenticator 
wiring still can’t construct an authenticator named `basic` 
(AuthenticatorFactory.AUTHENTICATORS only maps simple/oauth/kerberos). With 
`AUTHENTICATORS=basic`, the server will fail during 
`ServerAuthenticator.initialize()` (Class.forName("basic")). Add a BASIC 
mapping (and implementation) in the authenticator factory, or change this gate 
(and Idp*Manager.ensureBasicEnabled) to use an authenticator name that is 
actually supported at startup.



##########
core/build.gradle.kts:
##########
@@ -31,6 +31,7 @@ dependencies {
   implementation(project(":api"))
   implementation(project(":common"))
   implementation(project(":catalogs:catalog-common"))
+  implementation(project(":plugins:idp-basic"))

Review Comment:
   `core` now has a direct build dependency on `:plugins:idp-basic`. This 
couples the main server logic to an optional plugin module and violates the 
repo guideline to avoid adding new dependencies unless explicitly requested. If 
the only need is password hashing, consider moving the minimal hasher 
interface/factory into `common`/`core` (or using a service-loader abstraction) 
so `core` doesn’t depend on a plugin artifact.
   



##########
server/src/test/java/org/apache/gravitino/server/TestGravitinoServer.java:
##########
@@ -136,4 +171,149 @@ public void testMainShutdownHookShouldInvokeServerStop() 
throws IOException {
         hookBlock.contains("server.gracefulStop()"),
         "Shutdown hook should invoke server.gracefulStop() so app-level 
cleanup runs on SIGTERM");
   }
+
+  @Test
+  public void testInitializeRestApiWithBasicAuthenticator() throws Exception {
+    ServerConfig serverConfig = new ServerConfig();
+    serverConfig.loadFromMap(ImmutableMap.of(Configs.AUTHENTICATORS.getKey(), 
"basic"), t -> true);
+
+    GravitinoServer restServer = newRestApiTestServer(serverConfig, 
Collections.emptySet());
+    invokeInitializeRestApi(restServer);
+
+    IdpUserManager userManager = Mockito.mock(IdpUserManager.class);
+    Mockito.when(userManager.getUser("user1"))
+        .thenReturn(
+            
IdpUserDTO.builder().withName("user1").withGroups(Collections.emptyList()).build());
+
+    restServer.register(newIdpUserOperations(userManager));

Review Comment:
   This test only invokes `initializeRestApi()` via reflection, so it doesn’t 
exercise the real startup path where `ServerAuthenticator.initialize()` builds 
authenticators from `Configs.AUTHENTICATORS`. As a result, it can pass even if 
`AUTHENTICATORS=basic` would crash the server. Consider adding/adjusting a test 
to cover authenticator creation for the `basic` value (or run full 
`gravitinoServer.initialize()` with a basic config) so the IdP gating can’t 
regress.



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