World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#5987] improvement: Add more configurations for the config API (#5999)
roryqiba8df392c643
diff --git a/server/src/main/java/org/apache/gravitino/server/web/ConfigServlet.java b/server/src/main/java/org/apache/gravitino/server/web/ConfigServlet.javaindex cdce0a0b12..345a555cd9 100644--- a/server/src/main/java/org/apache/gravitino/server/web/ConfigServlet.java+++ b/server/src/main/java/org/apache/gravitino/server/web/ConfigServlet.java@@ -42,22 +42,20 @@ public class ConfigServlet extends HttpServlet {ImmutableSet.of(OAuthConfig.DEFAULT_SERVER_URI, OAuthConfig.DEFAULT_TOKEN_PATH);private static final ImmutableSet<ConfigEntry<?>> basicConfigEntries =- ImmutableSet.of(Configs.AUTHENTICATORS);+ ImmutableSet.of(Configs.AUTHENTICATORS, Configs.ENABLE_AUTHORIZATION);- private final Map<String, String> configs = Maps.newHashMap();+ private final Map<String, Object> configs = Maps.newHashMap();public ConfigServlet(ServerConfig serverConfig) {for (ConfigEntry<?> key : basicConfigEntries) {- String config = String.valueOf(serverConfig.get(key));- configs.put(key.getKey(), config);+ configs.put(key.getKey(), serverConfig.get(key));}if (serverConfig.get(Configs.AUTHENTICATORS).contains(AuthenticatorType.OAUTH.name().toLowerCase())) {for (ConfigEntry<?> key : oauthConfigEntries) {- String config = String.valueOf(serverConfig.get(key));- configs.put(key.getKey(), config);+ configs.put(key.getKey(), serverConfig.get(key));}}}diff --git a/server/src/test/java/org/apache/gravitino/server/web/TestConfigServlet.java b/server/src/test/java/org/apache/gravitino/server/web/TestConfigServlet.javanew file mode 100644index 0000000000..c76587d039--- /dev/null+++ b/server/src/test/java/org/apache/gravitino/server/web/TestConfigServlet.java@@ -0,0 +1,46 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */+package org.apache.gravitino.server.web;++import static org.mockito.Mockito.mock;+import static org.mockito.Mockito.verify;+import static org.mockito.Mockito.when;++import java.io.PrintWriter;+import javax.servlet.http.HttpServletResponse;+import org.apache.gravitino.server.ServerConfig;+import org.junit.jupiter.api.Test;++public class TestConfigServlet {++ @Test+ public void testConfigServlet() throws Exception {+ ServerConfig serverConfig = new ServerConfig();+ ConfigServlet configServlet = new ConfigServlet(serverConfig);+ configServlet.init();+ HttpServletResponse res = mock(HttpServletResponse.class);+ PrintWriter writer = mock(PrintWriter.class);+ when(res.getWriter()).thenReturn(writer);+ configServlet.doGet(null, res);+ verify(writer)+ .write(+ "{\"gravitino.authorization.enable\":false,\"gravitino.authenticators\":[\"simple\"]}");+ configServlet.destroy();+ }+}diff --git a/web/web/src/lib/store/auth/index.js b/web/web/src/lib/store/auth/index.jsindex 83d58394c9..ec0f1f5212 100644--- a/web/web/src/lib/store/auth/index.js+++ b/web/web/src/lib/store/auth/index.js@@ -40,7 +40,7 @@ export const getAuthConfigs = createAsyncThunk('auth/getAuthConfigs', async () =oauthUrl = `${res['gravitino.authenticator.oauth.serverUri']}${res['gravitino.authenticator.oauth.tokenPath']}`// ** get the first authenticator from the response. response example: "[simple, oauth]"- authType = res['gravitino.authenticators'].slice(1, -1).split(',')[0].trim()+ authType = res['gravitino.authenticators'][0].trim()localStorage.setItem('oauthUrl', oauthUrl)