gus-asf commented on code in PR #4120:
URL: https://github.com/apache/solr/pull/4120#discussion_r2785055781


##########
solr/core/src/java/org/apache/solr/servlet/AuthenticationFilter.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.solr.servlet;
+
+import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
+import static org.apache.solr.security.AuditEvent.EventType.ANONYMOUS;
+import static org.apache.solr.security.AuditEvent.EventType.AUTHENTICATED;
+import static org.apache.solr.security.AuditEvent.EventType.REJECTED;
+
+import io.opentelemetry.api.trace.Span;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.FilterConfig;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.security.AuthenticationPlugin;
+import org.apache.solr.security.PKIAuthenticationPlugin;
+import org.apache.solr.security.PublicKeyHandler;
+import org.apache.solr.util.tracing.TraceUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AuthenticationFilter extends CoreContainerAwareHttpFilter {
+
+  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+  public static final String PLUGIN_DID_NOT_SET_ERROR_STATUS =
+      "{} threw SolrAuthenticationException without setting request status >= 
400";
+
+  @Override
+  public void init(FilterConfig config) throws ServletException {
+    super.init(config);
+  }
+
+  @Override
+  protected void doFilter(HttpServletRequest req, HttpServletResponse res, 
FilterChain chain)
+      throws IOException, ServletException {
+
+    CoreContainer cc = getCores();
+    AuthenticationPlugin authenticationPlugin = cc.getAuthenticationPlugin();
+    String requestPath = ServletUtils.getPathAfterContext(req);
+
+    /////////////////////////////////////////////////////////
+    //////// Check cases where auth is not required. ////////
+    /////////////////////////////////////////////////////////

Review Comment:
   Why not? They make the intent of the section super clear and unlike the wall 
of text comments formerly associated with this code they are quick and easy to 
read. In this case it's pretty important to highlight that we are deliberately 
punching holes in the authentication. I **_REALLY_** don't want anyone to miss 
that point. One of the things I'm trying very hard to do here is to make it 
super simple to understand our authentication process here. Few things are more 
dangerous than misunderstood authentication code.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to