dimas-b commented on code in PR #3928: URL: https://github.com/apache/polaris/pull/3928#discussion_r2982980438
########## extensions/auth/ranger/src/main/java/org/apache/polaris/extension/auth/ranger/RangerPolarisAuthorizerConfig.java: ########## @@ -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. + */ +package org.apache.polaris.extension.auth.ranger; + +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithParentName; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; + +@ConfigMapping(prefix = "polaris.authorization.ranger") +public interface RangerPolarisAuthorizerConfig { + + static final String RANGER_KEY_PREFIX = "ranger."; + static final String XASECURE_KEY_PREFIX = "xasecure."; + + Optional<String> serviceName(); + + @WithParentName + Map<String, String> properties(); + + default Properties toRangerProperties() { + Properties props = new Properties(); + for (String key : properties().keySet()) { + if (!key.startsWith(RANGER_KEY_PREFIX) && !key.startsWith(XASECURE_KEY_PREFIX)) { + props.setProperty(RANGER_KEY_PREFIX + key, properties().get(key)); Review Comment: When can this happen in practice? ########## runtime/defaults/src/main/resources/application.properties: ########## @@ -264,6 +264,51 @@ polaris.oidc.principal-roles-mapper.type=default # polaris.authorization.opa.auth.bearer.file-based.jwt-expiration-refresh=true # polaris.authorization.opa.auth.bearer.file-based.jwt-expiration-buffer=PT1M +# Ranger authorizer +# polaris.authorization.type=ranger +# polaris.authorization.ranger.service-name=dev_polaris + +# polaris.authorization.ranger.authz.default.access.cluster.name=dev +# polaris.authorization.ranger.authz.default.policy.source.impl=org.apache.ranger.admin.client.RangerAdminRESTClient +# polaris.authorization.ranger.authz.default.policy.rest.url=http://ranger-admin:6080 +# polaris.authorization.ranger.authz.default.policy.rest.ssl.config.file= +# polaris.authorization.ranger.authz.default.policy.rest.client.connection.timeoutMs=120000 +# polaris.authorization.ranger.authz.default.policy.rest.client.read.timeoutMs=30000 +# polaris.authorization.ranger.authz.default.policy.rest.client.max.retry.attempts=3 +# polaris.authorization.ranger.authz.default.policy.rest.client.retry.interval.ms=1000 +# polaris.authorization.ranger.authz.default.policy.rest.client.cookie.enabled=true +# polaris.authorization.ranger.authz.default.policy.rest.client.session.cookie.name=RANGERADMINSESSIONID + +# Authenticate with Ranger using JWT +# valid sources for JWT: env, file, cred +# polaris.authorization.ranger.authz.default.policy.rest.jwt.source= Review Comment: These properties all handled by the Ranger library, right? Polaris code just passes them through, I guess? ########## extensions/auth/ranger/src/test/java/org/apache/polaris/extension/auth/ranger/RangerTestUtils.java: ########## @@ -0,0 +1,87 @@ +/* + * 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.extension.auth.ranger; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import org.apache.polaris.core.config.PolarisConfiguration; +import org.apache.polaris.core.config.RealmConfig; +import org.apache.polaris.core.entity.CatalogEntity; + +public class RangerTestUtils { + public static RangerPolarisAuthorizerConfig createConfig() { Review Comment: Having a `@QuarkusTest` is necessary to ensure all pieces work fine in runtime, IMHO. We can keep current tests, of course, and just do a simple smoke test in a `@QuarkusTest`. ########## extensions/auth/ranger/README.md: ########## @@ -0,0 +1,41 @@ +<!-- + + 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. + +--> + +# Prerequisites +Ranger authorizer for Polaris requires Apache Ranger version 2.8.0 or later. + +# Setup instructions +1. Enable Ranger authorizer by setting the following property in application.properties: +``` +polaris.authorization.type=ranger +``` + +2. Configure Ranger authorizer by setting configurations having name that start with "polaris.authorization.ranger." in application.properties, for example: +``` +polaris.authorization.ranger.service-name=dev_polaris +polaris.authorization.ranger.authz.default.policy.source.impl=org.apache.ranger.admin.client.RangerAdminRESTClient +polaris.authorization.ranger.authz.default.policy.rest.url=http://ranger-admin:6080 Review Comment: nit: Add examples for authentication in REST API calls? ########## gradle/libs.versions.toml: ########## @@ -19,12 +19,14 @@ [versions] checkstyle = "13.3.0" +graalvm = "25.0.2" Review Comment: Does this version depend on the Ranger version in any way? -- 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]
