himanshug commented on a change in pull request #8248: Add TrustedDomain 
Authenticator
URL: https://github.com/apache/incubator-druid/pull/8248#discussion_r316808477
 
 

 ##########
 File path: 
server/src/main/java/org/apache/druid/server/security/TrustedDomainAuthenticator.java
 ##########
 @@ -0,0 +1,164 @@
+/*
+ * 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.druid.server.security;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import org.apache.druid.java.util.common.logger.Logger;
+
+import javax.annotation.Nullable;
+import javax.servlet.DispatcherType;
+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 java.io.IOException;
+import java.util.EnumSet;
+import java.util.Map;
+
+/**
+ * Authenticates requests coming from a specific domain and directs them to an 
authorizer.
+ */
+@JsonTypeName(AuthConfig.TRUSTED_DOMAIN_NAME)
+public class TrustedDomainAuthenticator implements Authenticator
+{
+  private static final Logger LOGGER = new 
Logger(TrustedDomainAuthenticator.class);
+  private static final String DEFAULT_IDENTITY = "defaultUser";
+  private static final String X_FORWARDED_FOR = "X-Forwarded-For";
+
+  private static final boolean DEFAULT_USE_FORWARDED_HEADERS = false;
+  private final AuthenticationResult authenticationResult;
+  private final String domain;
+  private final boolean useForwardedHeaders;
+
+  @JsonCreator
+  public TrustedDomainAuthenticator(
+      @JsonProperty("name") String name,
+      @JsonProperty("domain") String domain,
+      @JsonProperty("useForwardedHeaders") Boolean useForwardedHeaders,
+      @JsonProperty("authorizerName") String authorizerName,
+      @JsonProperty("identity") String identity
+  )
+  {
+    Preconditions.checkArgument(!Strings.isNullOrEmpty(domain), "Invalid 
domain name %s", domain);
+    this.domain = domain;
+    this.useForwardedHeaders = useForwardedHeaders == null ? 
DEFAULT_USE_FORWARDED_HEADERS : useForwardedHeaders;
+    this.authenticationResult = new AuthenticationResult(
+        identity == null ? DEFAULT_IDENTITY : identity,
+        authorizerName,
+        name,
+        null
+    );
+  }
+
+  @Override
+  public Class<? extends Filter> getFilterClass()
+  {
+    return null;
+  }
+
+  @Override
+  public Map<String, String> getInitParameters()
+  {
+    return null;
 
 Review comment:
   can you please add `@Nullable` annotation to 
ServeletFilterHolder.getInitParameters() interace ?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to