errose28 commented on code in PR #6898:
URL: https://github.com/apache/ozone/pull/6898#discussion_r1676167732


##########
hadoop-hdds/common/src/main/resources/ozone-default.xml:
##########
@@ -1826,6 +1826,48 @@
       interfaces by setting it to 0.0.0.0.</description>
   </property>
 
+  <property>
+    <name>ozone.s3g.content.http.enabled</name>

Review Comment:
   Maybe `ozone.s3g.http.admin.content.enabled` or something similar to 
indicate what type of content we are referring to?



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/S3GatewayWebContentServer.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * 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.hadoop.ozone.s3;
+
+import com.google.common.base.Strings;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.hadoop.hdds.conf.MutableConfigurationSource;
+import org.apache.hadoop.hdds.server.http.BaseHttpServer;
+import org.apache.hadoop.hdds.server.http.ServletElementsFactory;
+import org.apache.hadoop.security.SecurityUtil;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
+import org.eclipse.jetty.servlet.FilterHolder;
+import org.eclipse.jetty.servlet.FilterMapping;
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_CONTENT_HTTPS_ADDRESS_KEY;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_CONTENT_HTTPS_BIND_HOST_KEY;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_CONTENT_HTTPS_BIND_PORT_DEFAULT;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_CONTENT_HTTP_ADDRESS_KEY;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_CONTENT_HTTP_BIND_HOST_KEY;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_CONTENT_HTTP_BIND_PORT_DEFAULT;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_CONTENT_HTTP_ENABLED_KEY;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_HTTP_AUTH_CONFIG_PREFIX;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_HTTP_AUTH_TYPE;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_HTTP_BIND_HOST_DEFAULT;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_KEYTAB_FILE;
+import static 
org.apache.hadoop.ozone.s3.S3GatewayConfigKeys.OZONE_S3G_WEB_AUTHENTICATION_KERBEROS_PRINCIPAL;
+import static 
org.apache.hadoop.ozone.s3secret.S3SecretConfigKeys.OZONE_S3G_SECRET_HTTP_AUTH_TYPE_KEY;
+import static 
org.apache.hadoop.ozone.s3secret.S3SecretConfigKeys.OZONE_S3G_SECRET_HTTP_AUTH_TYPE_DEFAULT;
+import static 
org.apache.hadoop.ozone.s3secret.S3SecretConfigKeys.OZONE_S3G_SECRET_HTTP_ENABLED_KEY;
+import static 
org.apache.hadoop.ozone.s3secret.S3SecretConfigKeys.OZONE_S3G_SECRET_HTTP_ENABLED_KEY_DEFAULT;
+import static 
org.apache.hadoop.security.authentication.server.AuthenticationFilter.AUTH_TYPE;
+
+/**
+ * HTTP server for serving static content and Ozone-specific endpoints (/conf, 
etc.).
+ */
+class S3GatewayWebContentServer extends BaseHttpServer {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(S3GatewayWebContentServer.class);
+
+  S3GatewayWebContentServer(MutableConfigurationSource conf, String name) 
throws IOException {
+    super(conf, name);
+    addServlet("icon", "/favicon.ico", IconServlet.class);
+    addSecretAuthentication(conf);
+  }
+
+  private void addSecretAuthentication(MutableConfigurationSource conf)
+      throws IOException {
+
+    if (conf.getBoolean(OZONE_S3G_SECRET_HTTP_ENABLED_KEY,
+        OZONE_S3G_SECRET_HTTP_ENABLED_KEY_DEFAULT)) {
+      String authType = conf.get(OZONE_S3G_SECRET_HTTP_AUTH_TYPE_KEY,
+          OZONE_S3G_SECRET_HTTP_AUTH_TYPE_DEFAULT);
+
+      if (UserGroupInformation.isSecurityEnabled()
+          && authType.equals("kerberos")) {
+        ServletHandler handler = getWebAppContext().getServletHandler();
+        Map<String, String> params = new HashMap<>();
+
+        String principalInConf =
+            conf.get(OZONE_S3G_WEB_AUTHENTICATION_KERBEROS_PRINCIPAL);
+        if (!Strings.isNullOrEmpty(principalInConf)) {
+          params.put("kerberos.principal", SecurityUtil.getServerPrincipal(
+              principalInConf, 
conf.get(OZONE_S3G_CONTENT_HTTP_BIND_HOST_KEY)));
+        }
+        String httpKeytab = conf.get(OZONE_S3G_KEYTAB_FILE);
+        if (!Strings.isNullOrEmpty(httpKeytab)) {
+          params.put("kerberos.keytab", httpKeytab);
+        }
+        params.put(AUTH_TYPE, "kerberos");
+
+        FilterHolder holder = ServletElementsFactory.createFilterHolder(
+            "secretAuthentication", AuthenticationFilter.class.getName(),
+            params);
+        FilterMapping filterMapping =
+            ServletElementsFactory.createFilterMapping(
+                "secretAuthentication",
+                new String[]{"/secret/*"});
+
+        handler.addFilter(holder, filterMapping);
+      } else {
+        LOG.error("Secret Endpoint should be secured with Kerberos");
+        throw new IllegalStateException("Secret Endpoint should be secured"
+            + " with Kerberos");
+      }
+    }
+  }
+
+  // FIXME make configurable

Review Comment:
   What does this mean? Aren't these settings configurable already?



##########
hadoop-ozone/dist/src/main/smoketest/s3/webui.robot:
##########
@@ -24,15 +24,12 @@ Suite Setup         Setup s3 tests
 Default Tags        no-bucket-type
 
 *** Variables ***
-${ENDPOINT_URL}       http://s3g:9878
-${BUCKET}             generated
+
+${S3G_WEB_UI}       http://s3g:19878
+
 
 *** Test Cases ***
 
-S3 Gateway Web UI
-    Run Keyword if      '${SECURITY_ENABLED}' == 'true'     Kinit HTTP user

Review Comment:
   Why were the tests in this section removed?



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3secret/Application.java:
##########
@@ -15,7 +15,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.hadoop.ozone.s3secret;
+
+import org.glassfish.jersey.server.ResourceConfig;
 
-window.onload = function () {
-    document.getElementById('s3gurl').innerHTML = window.location.origin;
-};

Review Comment:
   I don't know what the original purpose of s3g.js was or why git thinks this 
was the same file. Can you elaborate on the diff here?



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to