-
Notifications
You must be signed in to change notification settings - Fork 914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KYUUBI #3325] [FEATURE] [AUTHZ] Privilege checks for permanent views and skipping shadowed tables #3326
Closed
bowenliang123
wants to merge
15
commits into
apache:master
from
bowenliang123:feature-authz-perm-view
Closed
[KYUUBI #3325] [FEATURE] [AUTHZ] Privilege checks for permanent views and skipping shadowed tables #3326
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a0072c0
add PermanentViewMarker for marking perm view catalogTable and check …
bowenliang123 94a837f
add ut for permanent view privilege checks
bowenliang123 41c67ac
use reflection for isTempView of View
bowenliang123 aea561c
ut for spark30 and spark31greater
bowenliang123 76ec6b4
simplify and remove applyPermanentViewMarker (+2 squashed commits)
bowenliang123 6ef8131
use isSparkVersionAtLeast 3.1.0 instead of try-catch RuntimeException…
bowenliang123 3706dda
rename ViewAccessAnalysis to RuleApplyPermanentViewMarker (+2 squashe…
bowenliang123 78ff9d3
view casting (+1 squashed commit)
bowenliang123 4903f0a
change to use mergeProjection in PivilegesBuilder , checking column l…
bowenliang123 81e8b99
rename to hasResolvedPermanentView and check if plan resolved
bowenliang123 3cfb432
Merge branch 'master' into feature-authz-perm-view
bowenliang123 bcd35d3
add ut
bowenliang123 82c7ae6
fix case for #3326. add "view" type for withCleanTmpResources.
bowenliang123 b9d2cdb
fix ut
bowenliang123 468f47a
fix ut
bowenliang123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...main/scala/org/apache/kyuubi/plugin/spark/authz/ranger/RuleApplyPermanentViewMarker.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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.kyuubi.plugin.spark.authz.ranger | ||
|
||
import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, View} | ||
import org.apache.spark.sql.catalyst.rules.Rule | ||
|
||
import org.apache.kyuubi.plugin.spark.authz.util.AuthZUtils._ | ||
import org.apache.kyuubi.plugin.spark.authz.util.PermanentViewMarker | ||
|
||
/** | ||
* Adding [[org.apache.kyuubi.plugin.spark.authz.util.PermanentViewMarker]] for permanent views | ||
* for marking catalogTable of views used by privilege checking | ||
* in [[org.apache.kyuubi.plugin.spark.authz.ranger.RuleAuthorization]]. | ||
* [[org.apache.kyuubi.plugin.spark.authz.util.PermanentViewMarker]] must be transformed up later | ||
* in [[org.apache.kyuubi.plugin.spark.authz.util.RuleEliminateViewMarker]] optimizer. | ||
*/ | ||
class RuleApplyPermanentViewMarker extends Rule[LogicalPlan] { | ||
|
||
override def apply(plan: LogicalPlan): LogicalPlan = { | ||
plan mapChildren { | ||
case p: PermanentViewMarker => p | ||
case permanentView: View if hasResolvedPermanentView(permanentView) => | ||
PermanentViewMarker(permanentView, permanentView.desc) | ||
case other => apply(other) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/util/PermanentViewMarker.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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.kyuubi.plugin.spark.authz.util | ||
|
||
import org.apache.spark.sql.catalyst.catalog.CatalogTable | ||
import org.apache.spark.sql.catalyst.expressions.Attribute | ||
import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, UnaryNode} | ||
|
||
case class PermanentViewMarker(child: LogicalPlan, catalogTable: CatalogTable) extends UnaryNode | ||
with WithInternalChild { | ||
|
||
override def output: Seq[Attribute] = child.output | ||
|
||
override def withNewChildInternal(newChild: LogicalPlan): LogicalPlan = | ||
copy(child = newChild) | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...hz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/util/RuleEliminateViewMarker.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.kyuubi.plugin.spark.authz.util | ||
|
||
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
import org.apache.spark.sql.catalyst.rules.Rule | ||
|
||
/** | ||
* Transforming up [[org.apache.kyuubi.plugin.spark.authz.util.PermanentViewMarker]] | ||
*/ | ||
class RuleEliminateViewMarker extends Rule[LogicalPlan] { | ||
override def apply(plan: LogicalPlan): LogicalPlan = { | ||
plan.transformUp { case pvm: PermanentViewMarker => pvm.child } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks we need to change to the above one, we may still project a view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
Changed to mergeProjection, and checking column level privileges for perm views.