clintropolis commented on code in PR #18741: URL: https://github.com/apache/druid/pull/18741#discussion_r2528439580
########## embedded-tests/src/test/java/org/apache/druid/testing/embedded/auth/AllowAllWithPolicyAuthResource.java: ########## @@ -0,0 +1,183 @@ +/* + * 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.testing.embedded.auth; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.google.inject.Binder; +import com.google.inject.Key; +import com.google.inject.multibindings.MapBinder; +import org.apache.druid.guice.LazySingleton; +import org.apache.druid.guice.PolyBind; +import org.apache.druid.initialization.DruidModule; +import org.apache.druid.query.policy.NoRestrictionPolicy; +import org.apache.druid.server.security.Access; +import org.apache.druid.server.security.Action; +import org.apache.druid.server.security.AllowAllAuthenticator; +import org.apache.druid.server.security.AuthConfig; +import org.apache.druid.server.security.AuthenticationResult; +import org.apache.druid.server.security.Authenticator; +import org.apache.druid.server.security.AuthorizationUtils; +import org.apache.druid.server.security.Authorizer; +import org.apache.druid.server.security.NoopEscalator; +import org.apache.druid.server.security.Resource; +import org.apache.druid.testing.embedded.EmbeddedDruidCluster; +import org.apache.druid.testing.embedded.EmbeddedResource; + +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 java.io.IOException; +import java.util.List; +import java.util.Map; + +public class AllowAllWithPolicyAuthResource implements EmbeddedResource +{ + private static final String AUTH_TYPE = "actually-allow-all"; Review Comment: i named it this on discovering that `allowAll` does not actually allow everything if you have a policy enforcer configured because it does not set policies. I considered just fixing `allowAll` to be able to set the `NoRestrictionPolicy`, on the other hand there is probably limited scenario where you would have both allowAll and also a policy enforcer configured, and this has a somewhat ugly side-effect of setting a policy always (and so making a restricted datasource on the query) even if you don't have policy enforcement or policies of any sort, which seems a bit odd for out of the box behavior, so I did this instead. -- 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]
