dimas-b commented on code in PR #2680: URL: https://github.com/apache/polaris/pull/2680#discussion_r2422220845
########## runtime/service/src/intTest/java/org/apache/polaris/service/auth/opa/OpaFileTokenIntegrationTest.java: ########## @@ -0,0 +1,310 @@ +/* + * 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.polaris.service.auth.opa; + +import static io.restassured.RestAssured.given; +import static org.junit.jupiter.api.Assertions.fail; + +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusTestProfile; +import io.quarkus.test.junit.QuarkusTestProfile.TestResourceEntry; +import io.quarkus.test.junit.TestProfile; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.polaris.test.commons.OpaTestResource; +import org.junit.jupiter.api.Test; + +@QuarkusTest +@TestProfile(OpaFileTokenIntegrationTest.FileTokenOpaProfile.class) +public class OpaFileTokenIntegrationTest { Review Comment: Would it be possible to keep this test under `extensions/auth/opa/...` somewhere? In light of making OPA a proper plugin, it would be nice to avoid hard dependencies from the main service module. ########## runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java: ########## @@ -141,8 +141,13 @@ public RealmConfig realmConfig(CallContext callContext) { @Produces @RequestScoped - public PolarisAuthorizer polarisAuthorizer(RealmConfig realmConfig) { - return new PolarisAuthorizerImpl(realmConfig); + public PolarisAuthorizer polarisAuthorizer( + AuthorizationConfiguration authorizationConfig, + RealmConfig realmConfig, + @Any Instance<PolarisAuthorizerFactory> authorizerFactories) { + PolarisAuthorizerFactory factory = + authorizerFactories.select(Identifier.Literal.of(authorizationConfig.type())).get(); Review Comment: Could you move the factory into a separate `@ApplicationScoped` producer to avoid `.select()` calls on every request? ########## extensions/auth/opa/build.gradle.kts: ########## @@ -0,0 +1,56 @@ +/* + * 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. + */ + +plugins { + id("polaris-server") + id("org.kordamp.gradle.jandex") +} + +dependencies { + implementation(project(":polaris-core")) + implementation(project(":polaris-runtime-service")) Review Comment: why does OPA need `polaris-runtime-service`? ########## gradle/projects.main.properties: ########## @@ -43,6 +43,7 @@ polaris-version=tools/version polaris-misc-types=tools/misc-types polaris-extensions-federation-hadoop=extensions/federation/hadoop polaris-extensions-federation-hive=extensions/federation/hive +polaris-extensions-auth-opa=extensions/auth/opa Review Comment: nit: I'd personally be fine with `polaris-auth-opa` (for brevity). The module name does not have to repeat all sub-dir names of its location. I think the `polaris` prefix helps in case modules are imported into another project, but otherwise shorter name are easier to use, IMHO. ########## polaris-core/build.gradle.kts: ########## @@ -24,6 +24,7 @@ plugins { dependencies { implementation(project(":polaris-api-management-model")) + implementation(libs.apache.httpclient5) Review Comment: Do we still need this dep. in core? -- 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]
