-
Notifications
You must be signed in to change notification settings - Fork 601
[#7542] feat(authz): Support table authorization #7554
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
[#7542] feat(authz): Support table authorization #7554
Conversation
note: will rebase against #7536 after it's merged. |
server/src/main/java/org/apache/gravitino/server/web/rest/TableOperations.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java
Outdated
Show resolved
Hide resolved
...st/java/org/apache/gravitino/client/integration/test/authorization/TableAuthorizationIT.java
Show resolved
Hide resolved
...st/java/org/apache/gravitino/client/integration/test/authorization/TableAuthorizationIT.java
Show resolved
Hide resolved
5799fa3
to
12d8bdc
Compare
...st/java/org/apache/gravitino/client/integration/test/authorization/TableAuthorizationIT.java
Outdated
Show resolved
Hide resolved
…pport-table-auth # Conflicts: # core/src/main/java/org/apache/gravitino/authorization/OwnerManager.java # server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java # server/src/main/java/org/apache/gravitino/server/web/rest/SchemaOperations.java
All comment fixed, PHAL @jerqi |
server/src/main/java/org/apache/gravitino/server/web/rest/TableOperations.java
Outdated
Show resolved
Hide resolved
@@ -140,11 +164,21 @@ public Response createTable( | |||
@Produces("application/vnd.gravitino.v1+json") | |||
@Timed(name = "load-table." + MetricNames.HTTP_PROCESS_DURATION, absolute = true) | |||
@ResponseMetered(name = "load-table", absolute = true) | |||
@AuthorizationExpression( | |||
expression = | |||
"((ANY(USE_CATALOG,METALAKE,CATALOG)) && " |
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.
It's hard to review the expressions. is there any way to make it more readable? And add UT for the expression since it's complicated?
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.
Expanding the expressions inside the parentheses may make it easier to understand, but it could lead to OGNL repeatedly evaluating the same expression. I'm currently working on adding unit tests and exploring whether it's possible to implement boolean expression optimization.
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.
It's hard to review the expressions. is there any way to make it more readable? And add UT for the expression since it's complicated?
The authorization expression has been optimized. Please check if it meets the expectations.
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.
It's hard to review the expressions. is there any way to make it more readable? And add UT for the expression since it's complicated?
fixed
server/src/main/java/org/apache/gravitino/server/web/rest/TableOperations.java
Outdated
Show resolved
Hide resolved
" ((ANY(USE_CATALOG,METALAKE,CATALOG)) && " | ||
+ "((ANY(USE_SCHEMA,METALAKE,CATALOG,SCHEMA)) " | ||
+ "&& (ANY(CREATE_TABLE,METALAKE,CATALOG,SCHEMA)) || SCHEMA::OWNER)) || " | ||
+ "METALAKE::OWNER || CATALOG::OWNER", |
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.
Should we use ANY OWNER here?
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.
fixed
@AuthorizationExpression( | ||
expression = | ||
" ((ANY(USE_CATALOG,METALAKE,CATALOG)) && " | ||
+ "((ANY(USE_SCHEMA,METALAKE,CATALOG,SCHEMA)) " |
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.
rebundant ()
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.
fixed
@AuthorizationExpression( | ||
expression = | ||
"ANY(OWNER,METALAKE,CATALOG) ||" | ||
+ "SCHEMA::OWNER && ANY_USE_CATALOG ||" |
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.
Can we use expression to replace SCHEMA::OWNER && ANY_USE_CATALOG
, too?
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.
How about using SCHEMA_OWNER_WITH_USE_CATALOG
to replace? But it seems not shorter than CHEMA::OWNER && ANY_USE_CATALOG
😄.
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 for me. It's more clear for me.
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 for me. It's more clear for me.
OK, fixed, PHAL
Could use modify the schema and catalog operations according to new expression replacement? |
…le-auth # Conflicts: # server-common/src/main/java/org/apache/gravitino/server/authorization/expression/AuthorizationExpressionConverter.java
Fixed, PHAL |
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.
LGTM.
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.
LGTM
<!-- 1. Title: [#<issue>] <type>(<scope>): <subject> Examples: - "[apache#123] feat(operator): support xxx" - "[apache#233] fix: check null before access result in xxx" - "[MINOR] refactor: fix typo in variable name" - "[MINOR] docs: fix typo in README" - "[apache#255] test: fix flaky test NameOfTheTest" Reference: https://www.conventionalcommits.org/en/v1.0.0/ 2. If the PR is unfinished, please mark this PR as draft. --> ### What changes were proposed in this pull request? Support table authorization. ### Why are the changes needed? Fix: apache#7542 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? `org.apache.gravitino.client.integration.test.authorization.TableAuthorizationIT` --------- Co-authored-by: yangyang zhong <35210666+hdygxsj@users.noreply.github.com> Co-authored-by: 1161623489@qq.com <1161623489@qq.com>
<!-- 1. Title: [#<issue>] <type>(<scope>): <subject> Examples: - "[apache#123] feat(operator): support xxx" - "[apache#233] fix: check null before access result in xxx" - "[MINOR] refactor: fix typo in variable name" - "[MINOR] docs: fix typo in README" - "[apache#255] test: fix flaky test NameOfTheTest" Reference: https://www.conventionalcommits.org/en/v1.0.0/ 2. If the PR is unfinished, please mark this PR as draft. --> ### What changes were proposed in this pull request? Support table authorization. ### Why are the changes needed? Fix: apache#7542 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? `org.apache.gravitino.client.integration.test.authorization.TableAuthorizationIT` --------- Co-authored-by: yangyang zhong <35210666+hdygxsj@users.noreply.github.com> Co-authored-by: 1161623489@qq.com <1161623489@qq.com>
<!-- 1. Title: [#<issue>] <type>(<scope>): <subject> Examples: - "[#123] feat(operator): support xxx" - "[#233] fix: check null before access result in xxx" - "[MINOR] refactor: fix typo in variable name" - "[MINOR] docs: fix typo in README" - "[#255] test: fix flaky test NameOfTheTest" Reference: https://www.conventionalcommits.org/en/v1.0.0/ 2. If the PR is unfinished, please mark this PR as draft. --> ### What changes were proposed in this pull request? Support table authorization. ### Why are the changes needed? Fix: #7542 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? `org.apache.gravitino.client.integration.test.authorization.TableAuthorizationIT` --------- Co-authored-by: yangyang zhong <35210666+hdygxsj@users.noreply.github.com> Co-authored-by: 1161623489@qq.com <1161623489@qq.com>
<!-- 1. Title: [#<issue>] <type>(<scope>): <subject> Examples: - "[apache#123] feat(operator): support xxx" - "[apache#233] fix: check null before access result in xxx" - "[MINOR] refactor: fix typo in variable name" - "[MINOR] docs: fix typo in README" - "[apache#255] test: fix flaky test NameOfTheTest" Reference: https://www.conventionalcommits.org/en/v1.0.0/ 2. If the PR is unfinished, please mark this PR as draft. --> ### What changes were proposed in this pull request? Support table authorization. ### Why are the changes needed? Fix: apache#7542 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? `org.apache.gravitino.client.integration.test.authorization.TableAuthorizationIT` --------- Co-authored-by: yangyang zhong <35210666+hdygxsj@users.noreply.github.com> Co-authored-by: 1161623489@qq.com <1161623489@qq.com>
What changes were proposed in this pull request?
Support table authorization.
Why are the changes needed?
Fix: #7542
Does this PR introduce any user-facing change?
No.
How was this patch tested?
org.apache.gravitino.client.integration.test.authorization.TableAuthorizationIT