You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/09/02 06:26:20 UTC

[GitHub] [incubator-druid] nishantmonu51 commented on a change in pull request #8248: Add TrustedDomain Authenticator

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

 ##########
 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:
   added

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org