FrankChen021 commented on code in PR #19670: URL: https://github.com/apache/druid/pull/19670#discussion_r3558726645
########## extensions-contrib/druid-opa-authorizer/example/druid.rego: ########## @@ -0,0 +1,54 @@ +# 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 app.druid + +import rego.v1 + +# By default, deny requests. +default allow := false + +# Allow admins to do anything. +allow if { + user_is_admin +} + +# Allow the action if the user is granted permission to perform the action. +allow if { + # Find grants for the user. + some grant + user_is_granted[grant] + + # Check if the grant permits the action. + input.action == grant.action + regex.match(grant.resource.name, input.resource.name) Review Comment: [P2] Anchor resource-name policy matches `regex.match` permits substring matches, so the example grant for `ReportTable` also authorizes names such as `ReportTable_backup`. Users adopting this published policy can therefore grant access beyond the named datasource. Use a whole-string match or anchor the configured patterns. The embedded-test policy repeats this behavior at `embedded-tests/src/test/resources/opa-configs/druid.rego:11`. ########## extensions-contrib/druid-opa-authorizer/README.md: ########## @@ -0,0 +1,20 @@ +<!-- + ~ 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. + --> + +See [docs/development/extensions-contrib/druid-opa-authorizer.md](../../../docs/development/extensions-contrib/druid-opa-authorizer.md) for more details. Review Comment: [P3] Fix the repository-relative documentation link From this directory, `../../../docs/...` climbs one level too far and resolves outside the repository's versioned path, producing a broken link. The target should begin with `../../docs/...`. -- 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]
