sungwy commented on code in PR #2680: URL: https://github.com/apache/polaris/pull/2680#discussion_r2444917057
########## extensions/auth/opa/impl/src/main/java/org/apache/polaris/extension/auth/opa/OpaAuthorizationConfig.java: ########## @@ -0,0 +1,201 @@ +/* + * 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.opa; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.common.base.Strings; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; +import java.net.URI; +import java.nio.file.Path; +import java.time.Duration; +import java.util.Optional; + +/** + * Configuration for OPA (Open Policy Agent) authorization. + * + * <p><strong>Beta Feature:</strong> OPA authorization is currently in Beta and is not a stable + * release. It may undergo breaking changes in future versions. Use with caution in production + * environments. + */ +@ConfigMapping(prefix = "polaris.authorization.opa") +public interface OpaAuthorizationConfig { + + /** Authentication types supported by OPA authorization */ + enum AuthenticationType { + NONE("none"), + BEARER("bearer"); + + private final String value; + + AuthenticationType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + /** Bearer token configuration types */ + enum BearerTokenType { + STATIC_TOKEN("static-token"), + FILE_BASED("file-based"); + + private final String value; + + BearerTokenType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + Optional<URI> policyUri(); + + Optional<AuthenticationConfig> auth(); + + Optional<HttpConfig> http(); Review Comment: Thanks @snazy ! I was just about to do another round of self-review today to address these. Thanks so much for jumping in and reviewing my changes so quickly — that’s a big help. I had run into some issues earlier with SmallRye Config when using required fields in an optional config (like FileBasedConfig) together with `@WithDefault`. I’ve learned a bit more about how the library behaves and resolved those problems, so I agree that removing these should be fine. ########## extensions/auth/opa/impl/src/main/java/org/apache/polaris/extension/auth/opa/OpaAuthorizationConfig.java: ########## @@ -0,0 +1,201 @@ +/* + * 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.opa; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.common.base.Strings; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; +import java.net.URI; +import java.nio.file.Path; +import java.time.Duration; +import java.util.Optional; + +/** + * Configuration for OPA (Open Policy Agent) authorization. + * + * <p><strong>Beta Feature:</strong> OPA authorization is currently in Beta and is not a stable + * release. It may undergo breaking changes in future versions. Use with caution in production + * environments. + */ +@ConfigMapping(prefix = "polaris.authorization.opa") +public interface OpaAuthorizationConfig { + + /** Authentication types supported by OPA authorization */ + enum AuthenticationType { + NONE("none"), + BEARER("bearer"); + + private final String value; + + AuthenticationType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + /** Bearer token configuration types */ + enum BearerTokenType { + STATIC_TOKEN("static-token"), + FILE_BASED("file-based"); + + private final String value; + + BearerTokenType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + Optional<URI> policyUri(); + + Optional<AuthenticationConfig> auth(); + + Optional<HttpConfig> http(); Review Comment: Thanks @snazy ! I was just about to do another round of self-review today to address these. Thanks so much for jumping in and reviewing my changes so quickly, that’s a big help. I had run into some issues earlier with SmallRye Config when using required fields in an optional config (like FileBasedConfig) together with `@WithDefault`. I’ve learned a bit more about how the library behaves and resolved those problems, so I agree that removing these should be fine. -- 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]
