You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/09/20 18:12:44 UTC

[GitHub] [ozone] adoroszlai commented on a change in pull request #2655: HDDS-5612. Create Ozone s3 authentication token and client authentication transport

adoroszlai commented on a change in pull request #2655:
URL: https://github.com/apache/ozone/pull/2655#discussion_r712384845



##########
File path: hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientProducer.java
##########
@@ -17,35 +17,28 @@
  */
 package org.apache.hadoop.ozone.s3;
 
-import javax.annotation.PreDestroy;
+//import javax.annotation.PreDestroy;
+//import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.inject.Produces;
 import javax.inject.Inject;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.core.Context;
 import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.security.PrivilegedExceptionAction;
 
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.io.Text;
-import org.apache.hadoop.ozone.OzoneSecurityUtil;
 import org.apache.hadoop.ozone.client.OzoneClient;
 import org.apache.hadoop.ozone.client.OzoneClientFactory;
 import org.apache.hadoop.ozone.s3.exception.OS3Exception;
-import org.apache.hadoop.ozone.s3.signature.SignatureInfo;
-import org.apache.hadoop.ozone.s3.signature.SignatureInfo.Version;
-import org.apache.hadoop.ozone.s3.signature.SignatureProcessor;
-import org.apache.hadoop.ozone.s3.signature.StringToSignProducer;
-import org.apache.hadoop.ozone.security.OzoneTokenIdentifier;
 import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.security.token.Token;
 
 import com.google.common.annotations.VisibleForTesting;
-import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMTokenProto.Type.S3AUTHINFO;
-import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INTERNAL_ERROR;
-import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.MALFORMED_HEADER;
+import static org.apache.hadoop.ozone.s3.exception
+    .S3ErrorTable.INTERNAL_ERROR;
+import static org.apache.hadoop.ozone.s3.exception
+    .S3ErrorTable.MALFORMED_HEADER;

Review comment:
       Please avoid unnecessary reformatting.

##########
File path: hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/UgiFilter.java
##########
@@ -0,0 +1,169 @@
+/*
+ * 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 org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.ozone.OzoneSecurityUtil;
+import org.apache.hadoop.ozone.s3.exception.OS3Exception;
+import org.apache.hadoop.ozone.s3.signature.SignatureInfo;
+import org.apache.hadoop.ozone.s3.signature.StringToSignProducer;
+import org.apache.hadoop.ozone.security.OzoneTokenIdentifier;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.token.Token;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.WebApplicationException;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.PrivilegedExceptionAction;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Enumeration;
+import org.apache.hadoop.ozone.s3.signature.AWSSignatureProcessor;
+
+import com.google.common.annotations.VisibleForTesting;
+import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMTokenProto.Type.S3AUTHINFO;
+import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.MALFORMED_HEADER;
+
+/**
+ * Preprocessing filter for every request.
+ * - creates OzoneToken containing aws signature
+ * aws id and stringToSign for aws authenication;  stores OzoneToken in
+ * thread local variable (UserGroupInformation object) avail to all
+ * s3 rest command endpoints
+ */
+public class UgiFilter implements Filter {
+  public static final Logger LOG = LoggerFactory.getLogger(UgiFilter.class);
+
+  @Inject
+  private OzoneConfiguration ozoneConfiguration;
+  @Inject
+  private Text omService;
+
+  @Override
+  public void init(FilterConfig filterConfig) throws ServletException {
+
+  }
+
+  @Override
+  public void doFilter(ServletRequest servletRequest,
+                       ServletResponse servletResponse, FilterChain filterChain)
+      throws IOException, ServletException {
+    Map<String, String> headerMap = new HashMap<>();
+    HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
+    Enumeration<String> headerNames = httpRequest.getHeaderNames();
+    while (headerNames.hasMoreElements()) {
+      String headerKey = headerNames.nextElement();
+      headerMap.put(headerKey, httpRequest.getHeader(headerKey));
+      LOG.info("request {} : {}", headerKey, httpRequest.getHeader(headerKey));
+    }
+    AWSSignatureProcessor signature = new AWSSignatureProcessor(headerMap,
+        httpRequest.getParameterMap());
+    SignatureInfo signatureInfo;
+    String stringToSign = "";
+    String awsAccessId = "";
+    try {
+      signatureInfo = signature.parseSignature();
+      if (signatureInfo.getVersion() == SignatureInfo.Version.V4) {
+        stringToSign =
+            StringToSignProducer.createSignatureBase(signatureInfo,
+                httpRequest.getScheme(),
+                httpRequest.getMethod(),
+                httpRequest.getPathInfo(),
+                AWSSignatureProcessor.LowerCaseKeyStringMap
+                    .fromHeaderMap(headerMap),
+                StringToSignProducer.fromMultiValueToSingleValueMap(
+                    httpRequest.getParameterMap()));
+      }
+      awsAccessId = signatureInfo.getAwsAccessId();
+      validateAccessId(awsAccessId);
+    } catch (Throwable t) {
+      throw new IOException(t);
+    }
+
+    UserGroupInformation remoteUser =
+        UserGroupInformation.createRemoteUser(awsAccessId);
+
+    if (OzoneSecurityUtil.isSecurityEnabled(ozoneConfiguration)) {
+      LOG.debug("Creating s3 auth info for client.");
+
+      if (signatureInfo.getVersion() == SignatureInfo.Version.NONE) {
+        //throw MALFORMED_HEADER;
+        throw new IOException("MALFORMED_HEADER");
+      }
+
+      OzoneTokenIdentifier identifier = new OzoneTokenIdentifier();
+      identifier.setTokenType(S3AUTHINFO);
+      identifier.setStrToSign(stringToSign);
+      identifier.setSignature(signatureInfo.getSignature());
+      identifier.setAwsAccessId(awsAccessId);
+      identifier.setOwner(new Text(awsAccessId));
+      if (LOG.isTraceEnabled()) {
+        LOG.trace("Adding token for service:{}", omService);
+      }
+      Token<OzoneTokenIdentifier> token = new Token(identifier.getBytes(),
+          identifier.getSignature().getBytes(StandardCharsets.UTF_8),
+          identifier.getKind(),
+          omService);
+      remoteUser.addToken(token);
+    }
+    try {
+      remoteUser.doAs((PrivilegedExceptionAction<Void>) () -> {
+        filterChain.doFilter(httpRequest, servletResponse);
+        return null;
+      });
+    } catch (InterruptedException e) {
+      throw new IOException("Interrupted thread call doAs", e);
+    }
+  }
+
+  @Override
+  public void destroy() { }
+
+  private WebApplicationException wrapOS3Exception(OS3Exception os3Exception) {
+    return new WebApplicationException(os3Exception,
+        os3Exception.getHttpCode());
+  }
+
+  private void validateAccessId(String awsAccessId) throws Exception {
+    if (awsAccessId == null || awsAccessId.equals("")) {
+      LOG.error("Malformed s3 header. awsAccessID: ", awsAccessId);

Review comment:
       ```suggestion
         LOG.error("Malformed s3 header. awsAccessID: {}", awsAccessId);
   ```

##########
File path: hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientCache.java
##########
@@ -0,0 +1,73 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.client.OzoneClient;
+import org.apache.hadoop.ozone.client.OzoneClientFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.ApplicationScoped;
+import java.io.IOException;
+
+/**
+ * Cached ozone client for s3 requests.
+ */
+@ApplicationScoped
+public final class OzoneClientCache {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OzoneClientCache.class);
+  // single, cached OzoneClient established on first connection
+  // for s3g gRPC OmTransport, OmRequest - OmResponse channel
+  private static OzoneClientCache instance;
+  private OzoneClient client;
+
+  private OzoneClientCache(String omServiceID,
+                           OzoneConfiguration ozoneConfiguration)
+      throws IOException {
+    try {
+      if (omServiceID == null) {
+        client = OzoneClientFactory.getRpcClient(ozoneConfiguration);
+      } else {
+        // As in HA case, we need to pass om service ID.
+        client = OzoneClientFactory.getRpcClient(omServiceID,
+            ozoneConfiguration);
+      }
+    } catch (IOException e) {
+      LOG.warn("cannot create OzoneClient");

Review comment:
       I think the stack trace would be useful for diagnosing any potential problems.
   
   ```suggestion
         LOG.warn("cannot create OzoneClient", e);
   ```

##########
File path: hadoop-ozone/s3gateway/src/main/resources/webapps/s3gateway/WEB-INF/web.xml
##########
@@ -32,6 +32,11 @@
     <filter-class>org.apache.hadoop.ozone.s3.EmptyContentTypeFilter
     </filter-class>
   </filter>
+  <filter>
+    <filter-name>perrequest-preprocess-signaturelocalthread</filter-name>
+    <filter-class>org.apache.hadoop.ozone.s3.UgiFilter
+    </filter-class>

Review comment:
       ```suggestion
       <filter-class>org.apache.hadoop.ozone.s3.UgiFilter</filter-class>
   ```

##########
File path: hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
##########
@@ -184,6 +184,10 @@ message OMRequest {
   optional RevokeS3SecretRequest            RevokeS3SecretRequest          = 93;
 
   optional PurgePathsRequest                purgePathsRequest              = 94;
+
+  optional string                           stringToSign                   = 95;
+  optional string                           signature                      = 96;
+  optional string                           awsAccessId                    = 97;

Review comment:
       This seems to be specific to S3.  Can we make it a bit more generic (e.g. `accessId`)?  Also, should these couple of strings be wrapped in a structure?

##########
File path: hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientProducer.java
##########
@@ -17,35 +17,28 @@
  */
 package org.apache.hadoop.ozone.s3;
 
-import javax.annotation.PreDestroy;
+//import javax.annotation.PreDestroy;
+//import javax.enterprise.context.ApplicationScoped;

Review comment:
       Can these be omitted?

##########
File path: hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/signature/AWSSignatureProcessor.java
##########
@@ -41,19 +39,26 @@
  * header. For more details refer to AWS documentation https://docs.aws
  * .amazon.com/general/latest/gr/sigv4-create-canonical-request.html.
  **/
-@RequestScoped
+
 public class AWSSignatureProcessor implements SignatureProcessor {
 
   private static final Logger LOG =
       LoggerFactory.getLogger(AWSSignatureProcessor.class);
 
   @Context
   private ContainerRequestContext context;

Review comment:
       `context` is no longer used.

##########
File path: hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientProducer.java
##########
@@ -83,65 +75,20 @@ public OzoneClient createClient() throws WebApplicationException,
     return client;
   }
 
-  @PreDestroy
-  public void destroy() throws IOException {
-    client.close();
-  }
-
   private OzoneClient getClient(OzoneConfiguration config)
       throws WebApplicationException {
     OzoneClient ozoneClient = null;
     try {
-      SignatureInfo signatureInfo = signatureProcessor.parseSignature();
-
-      String stringToSign = "";
-      if (signatureInfo.getVersion() == Version.V4) {
-        stringToSign =
-            StringToSignProducer.createSignatureBase(signatureInfo, context);
-      }
-
-      String awsAccessId = signatureInfo.getAwsAccessId();
-      validateAccessId(awsAccessId);
-
-      UserGroupInformation remoteUser =
-          UserGroupInformation.createRemoteUser(awsAccessId);
-      if (OzoneSecurityUtil.isSecurityEnabled(config)) {
-        LOG.debug("Creating s3 auth info for client.");
-
-        if (signatureInfo.getVersion() == Version.NONE) {
-          throw MALFORMED_HEADER;
-        }
-
-        OzoneTokenIdentifier identifier = new OzoneTokenIdentifier();
-        identifier.setTokenType(S3AUTHINFO);
-        identifier.setStrToSign(stringToSign);
-        identifier.setSignature(signatureInfo.getSignature());
-        identifier.setAwsAccessId(awsAccessId);
-        identifier.setOwner(new Text(awsAccessId));
-        if (LOG.isTraceEnabled()) {
-          LOG.trace("Adding token for service:{}", omService);
-        }
-        Token<OzoneTokenIdentifier> token = new Token(identifier.getBytes(),
-            identifier.getSignature().getBytes(StandardCharsets.UTF_8),
-            identifier.getKind(),
-            omService);
-        remoteUser.addToken(token);
 
-      }
+      this.remoteUser = UserGroupInformation.getCurrentUser();
       ozoneClient =
-          remoteUser.doAs((PrivilegedExceptionAction<OzoneClient>) () -> {
-            return createOzoneClient();
-          });
-    } catch (OS3Exception ex) {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Error during Client Creation: ", ex);
-      }
-      throw wrapOS3Exception(ex);
-    } catch (Exception e) {
+          OzoneClientCache.getOzoneClientInstance(omServiceID,
+              ozoneConfiguration);
+    } catch (Throwable t) {

Review comment:
       `Throwable t` was changed to `Exception e` to avoid catching `OutOfMemoryError` and other errors.  Please do not revert it back.

##########
File path: hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientProducer.java
##########
@@ -83,65 +75,20 @@ public OzoneClient createClient() throws WebApplicationException,
     return client;
   }
 
-  @PreDestroy
-  public void destroy() throws IOException {
-    client.close();
-  }
-
   private OzoneClient getClient(OzoneConfiguration config)
       throws WebApplicationException {
     OzoneClient ozoneClient = null;
     try {
-      SignatureInfo signatureInfo = signatureProcessor.parseSignature();
-
-      String stringToSign = "";
-      if (signatureInfo.getVersion() == Version.V4) {
-        stringToSign =
-            StringToSignProducer.createSignatureBase(signatureInfo, context);
-      }
-
-      String awsAccessId = signatureInfo.getAwsAccessId();
-      validateAccessId(awsAccessId);
-
-      UserGroupInformation remoteUser =
-          UserGroupInformation.createRemoteUser(awsAccessId);
-      if (OzoneSecurityUtil.isSecurityEnabled(config)) {
-        LOG.debug("Creating s3 auth info for client.");
-
-        if (signatureInfo.getVersion() == Version.NONE) {
-          throw MALFORMED_HEADER;
-        }
-
-        OzoneTokenIdentifier identifier = new OzoneTokenIdentifier();
-        identifier.setTokenType(S3AUTHINFO);
-        identifier.setStrToSign(stringToSign);
-        identifier.setSignature(signatureInfo.getSignature());
-        identifier.setAwsAccessId(awsAccessId);
-        identifier.setOwner(new Text(awsAccessId));
-        if (LOG.isTraceEnabled()) {
-          LOG.trace("Adding token for service:{}", omService);
-        }
-        Token<OzoneTokenIdentifier> token = new Token(identifier.getBytes(),
-            identifier.getSignature().getBytes(StandardCharsets.UTF_8),
-            identifier.getKind(),
-            omService);
-        remoteUser.addToken(token);
 
-      }
+      this.remoteUser = UserGroupInformation.getCurrentUser();

Review comment:
       Seems to be unused.

##########
File path: hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/UgiFilter.java
##########
@@ -0,0 +1,169 @@
+/*
+ * 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 org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.ozone.OzoneSecurityUtil;
+import org.apache.hadoop.ozone.s3.exception.OS3Exception;
+import org.apache.hadoop.ozone.s3.signature.SignatureInfo;
+import org.apache.hadoop.ozone.s3.signature.StringToSignProducer;
+import org.apache.hadoop.ozone.security.OzoneTokenIdentifier;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.token.Token;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.WebApplicationException;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.PrivilegedExceptionAction;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Enumeration;
+import org.apache.hadoop.ozone.s3.signature.AWSSignatureProcessor;
+
+import com.google.common.annotations.VisibleForTesting;
+import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMTokenProto.Type.S3AUTHINFO;
+import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.MALFORMED_HEADER;
+
+/**
+ * Preprocessing filter for every request.
+ * - creates OzoneToken containing aws signature
+ * aws id and stringToSign for aws authenication;  stores OzoneToken in
+ * thread local variable (UserGroupInformation object) avail to all
+ * s3 rest command endpoints
+ */
+public class UgiFilter implements Filter {
+  public static final Logger LOG = LoggerFactory.getLogger(UgiFilter.class);
+
+  @Inject
+  private OzoneConfiguration ozoneConfiguration;
+  @Inject
+  private Text omService;
+
+  @Override
+  public void init(FilterConfig filterConfig) throws ServletException {
+
+  }
+
+  @Override
+  public void doFilter(ServletRequest servletRequest,
+                       ServletResponse servletResponse, FilterChain filterChain)
+      throws IOException, ServletException {
+    Map<String, String> headerMap = new HashMap<>();
+    HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
+    Enumeration<String> headerNames = httpRequest.getHeaderNames();
+    while (headerNames.hasMoreElements()) {
+      String headerKey = headerNames.nextElement();
+      headerMap.put(headerKey, httpRequest.getHeader(headerKey));
+      LOG.info("request {} : {}", headerKey, httpRequest.getHeader(headerKey));
+    }
+    AWSSignatureProcessor signature = new AWSSignatureProcessor(headerMap,
+        httpRequest.getParameterMap());
+    SignatureInfo signatureInfo;
+    String stringToSign = "";
+    String awsAccessId = "";
+    try {
+      signatureInfo = signature.parseSignature();
+      if (signatureInfo.getVersion() == SignatureInfo.Version.V4) {
+        stringToSign =
+            StringToSignProducer.createSignatureBase(signatureInfo,
+                httpRequest.getScheme(),
+                httpRequest.getMethod(),
+                httpRequest.getPathInfo(),
+                AWSSignatureProcessor.LowerCaseKeyStringMap
+                    .fromHeaderMap(headerMap),
+                StringToSignProducer.fromMultiValueToSingleValueMap(
+                    httpRequest.getParameterMap()));
+      }
+      awsAccessId = signatureInfo.getAwsAccessId();
+      validateAccessId(awsAccessId);
+    } catch (Throwable t) {
+      throw new IOException(t);
+    }
+
+    UserGroupInformation remoteUser =
+        UserGroupInformation.createRemoteUser(awsAccessId);
+
+    if (OzoneSecurityUtil.isSecurityEnabled(ozoneConfiguration)) {
+      LOG.debug("Creating s3 auth info for client.");
+
+      if (signatureInfo.getVersion() == SignatureInfo.Version.NONE) {
+        //throw MALFORMED_HEADER;
+        throw new IOException("MALFORMED_HEADER");
+      }
+
+      OzoneTokenIdentifier identifier = new OzoneTokenIdentifier();
+      identifier.setTokenType(S3AUTHINFO);
+      identifier.setStrToSign(stringToSign);
+      identifier.setSignature(signatureInfo.getSignature());
+      identifier.setAwsAccessId(awsAccessId);
+      identifier.setOwner(new Text(awsAccessId));
+      if (LOG.isTraceEnabled()) {
+        LOG.trace("Adding token for service:{}", omService);
+      }
+      Token<OzoneTokenIdentifier> token = new Token(identifier.getBytes(),
+          identifier.getSignature().getBytes(StandardCharsets.UTF_8),
+          identifier.getKind(),
+          omService);
+      remoteUser.addToken(token);
+    }
+    try {
+      remoteUser.doAs((PrivilegedExceptionAction<Void>) () -> {
+        filterChain.doFilter(httpRequest, servletResponse);
+        return null;
+      });
+    } catch (InterruptedException e) {
+      throw new IOException("Interrupted thread call doAs", e);
+    }
+  }
+
+  @Override
+  public void destroy() { }
+
+  private WebApplicationException wrapOS3Exception(OS3Exception os3Exception) {
+    return new WebApplicationException(os3Exception,
+        os3Exception.getHttpCode());
+  }
+
+  private void validateAccessId(String awsAccessId) throws Exception {
+    if (awsAccessId == null || awsAccessId.equals("")) {
+      LOG.error("Malformed s3 header. awsAccessID: ", awsAccessId);
+      throw wrapOS3Exception(MALFORMED_HEADER);
+    }
+  }

Review comment:
       Is access ID validation going to be refined in a later patch, or is this all that's needed?




-- 
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-unsubscribe@ozone.apache.org

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



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