cmccabe commented on a change in pull request #11649:
URL: https://github.com/apache/kafka/pull/11649#discussion_r801167657



##########
File path: 
metadata/src/main/java/org/apache/kafka/metadata/authorizer/StandardAuthorizer.java
##########
@@ -0,0 +1,179 @@
+/*
+ * 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.kafka.metadata.authorizer;
+
+import org.apache.kafka.common.Endpoint;
+import org.apache.kafka.common.Uuid;
+import org.apache.kafka.common.acl.AclBinding;
+import org.apache.kafka.common.acl.AclBindingFilter;
+import org.apache.kafka.common.errors.NotControllerException;
+import org.apache.kafka.common.errors.TimeoutException;
+import org.apache.kafka.server.authorizer.Action;
+import org.apache.kafka.server.authorizer.AuthorizableRequestContext;
+import org.apache.kafka.server.authorizer.AuthorizationResult;
+import org.apache.kafka.server.authorizer.AuthorizerServerInfo;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+
+import static org.apache.kafka.server.authorizer.AuthorizationResult.ALLOWED;
+import static org.apache.kafka.server.authorizer.AuthorizationResult.DENIED;
+
+
+/**
+ * The standard authorizer which is used in KRaft-based clusters if no other 
authorizer is
+ * configured.
+ */
+public class StandardAuthorizer implements ClusterMetadataAuthorizer {
+    public final static String SUPER_USERS_CONFIG = "super.users";
+
+    public final static String ALLOW_EVERYONE_IF_NO_ACL_IS_FOUND_CONFIG = 
"allow.everyone.if.no.acl.found";
+
+    /**
+     * A future which is completed once we have loaded a snapshot.
+     * TODO: complete this when we reach the high water mark.
+     */
+    private final CompletableFuture<Void> initialLoadFuture = 
CompletableFuture.completedFuture(null);
+
+    /**
+     * The current data. Can be read without a lock. Must be written while 
holding the object lock.

Review comment:
       Otherwise you could have the lost updates problem, where we are 
generating a new StandardAuthorizerData B based on A, but then someone comes 
along and generates a C based on A that doesn't include the updates in B.
   
   I don't think this is really a problem in practice due to the way we invoke 
these functions, but there's no reason to design the code to be vulnerable to 
this race condition. `setAclMutator` and `configure` are called only once, and 
`loadSnapshot` is called rarely, so getting rid of the lock would have no 
performance benefit. We don't need a lock for the other functions, which 
represent the vast majority of all calls.




-- 
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: jira-unsubscr...@kafka.apache.org

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


Reply via email to