You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "hdygxsj (via GitHub)" <gi...@apache.org> on 2025/06/20 15:32:55 UTC
[PR] [#7449]feat(authz): Support Catalog Authorization [gravitino]
hdygxsj opened a new pull request, #7450:
URL: https://github.com/apache/gravitino/pull/7450
### What changes were proposed in this pull request?
Support Catalog Authorization
### Why are the changes needed?
(Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, describe the bug.)
Fix: #7449
### Does this PR introduce _any_ user-facing change?
None
### How was this patch tested?
org.apache.gravitino.integration.test.rest.CatalogIT
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7449]feat(authz): Support Catalog Authorization [gravitino]
Posted by "hdygxsj (via GitHub)" <gi...@apache.org>.
hdygxsj commented on code in PR #7450:
URL: https://github.com/apache/gravitino/pull/7450#discussion_r2174795002
##########
core/src/main/java/org/apache/gravitino/Configs.java:
##########
@@ -285,6 +285,13 @@ private Configs() {}
.booleanConf()
.createWithDefault(false);
+ public static final ConfigEntry<String> AUTHORIZATION_IMPL =
+ new ConfigBuilder("gravitino.authorization.impl")
+ .doc("Metadata authorization implement")
Review Comment:
fixed
##########
core/src/main/java/org/apache/gravitino/Configs.java:
##########
@@ -285,6 +285,13 @@ private Configs() {}
.booleanConf()
.createWithDefault(false);
+ public static final ConfigEntry<String> AUTHORIZATION_IMPL =
+ new ConfigBuilder("gravitino.authorization.impl")
+ .doc("Metadata authorization implement")
+ .version(ConfigConstants.VERSION_1_0_0)
+ .stringConf()
+ .createWithDefault("PassThrough");
Review Comment:
fixed
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7449]feat(authz): Support Catalog Authorization [gravitino]
Posted by "xunliu (via GitHub)" <gi...@apache.org>.
xunliu commented on code in PR #7450:
URL: https://github.com/apache/gravitino/pull/7450#discussion_r2174051029
##########
core/src/main/java/org/apache/gravitino/Configs.java:
##########
@@ -285,6 +285,13 @@ private Configs() {}
.booleanConf()
.createWithDefault(false);
+ public static final ConfigEntry<String> AUTHORIZATION_TYPE =
+ new ConfigBuilder("gravitino.authorization.type")
+ .doc("Enable the authorization")
+ .version(ConfigConstants.VERSION_1_0_0)
+ .stringConf()
+ .createWithDefault("pass");
Review Comment:
```
public static final ConfigEntry<String> AUTHORIZATION_IMPL =
new ConfigBuilder("gravitino.authorization.impl")
.doc("Metadata authorization implement")
.version(ConfigConstants.VERSION_1_0_0)
.stringConf()
.createWithDefault("PassThrough");
```
##########
server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java:
##########
@@ -82,23 +83,28 @@ private static class MetadataAuthorizationMethodInterceptor implements MethodInt
*/
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
- Method method = methodInvocation.getMethod();
- Parameter[] parameters = method.getParameters();
- AuthorizationExpression expressionAnnotation =
- method.getAnnotation(AuthorizationExpression.class);
- if (expressionAnnotation != null) {
- String expression = expressionAnnotation.expression();
- Object[] args = methodInvocation.getArguments();
- Map<Entity.EntityType, NameIdentifier> metadataContext =
- extractNameIdentifierFromParameters(parameters, args);
- AuthorizationExpressionEvaluator authorizationExpressionEvaluator =
- new AuthorizationExpressionEvaluator(expression);
- boolean authorizeResult = authorizationExpressionEvaluator.evaluate(metadataContext);
- if (!authorizeResult) {
- return Utils.internalError("Can not access metadata.");
+ try {
+ Method method = methodInvocation.getMethod();
+ Parameter[] parameters = method.getParameters();
+ AuthorizationExpression expressionAnnotation =
+ method.getAnnotation(AuthorizationExpression.class);
+ if (expressionAnnotation != null) {
+ String expression = expressionAnnotation.expression();
+ Object[] args = methodInvocation.getArguments();
+ Map<Entity.EntityType, NameIdentifier> metadataContext =
+ extractNameIdentifierFromParameters(parameters, args);
+ AuthorizationExpressionEvaluator authorizationExpressionEvaluator =
+ new AuthorizationExpressionEvaluator(expression);
+ boolean authorizeResult = authorizationExpressionEvaluator.evaluate(metadataContext);
+ if (!authorizeResult) {
+ return Utils.forbidden(
+ "Can not access metadata.", new ForbiddenException("Can not access metadata."));
+ }
Review Comment:
```
"Can not access metadata {metalake1.catalog1.xxxx}.", new ForbiddenException("Can not access metadata {metalake1.catalog1.xxxx}."));
```
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7449]feat(authz): Support Catalog Authorization [gravitino]
Posted by "xunliu (via GitHub)" <gi...@apache.org>.
xunliu merged PR #7450:
URL: https://github.com/apache/gravitino/pull/7450
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7449]feat(authz): Support Catalog Authorization [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on PR #7450:
URL: https://github.com/apache/gravitino/pull/7450#issuecomment-3018773031
LGTM, let others take a look.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7449]feat(authz): Support Catalog Authorization [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7450:
URL: https://github.com/apache/gravitino/pull/7450#discussion_r2174385518
##########
core/src/main/java/org/apache/gravitino/Configs.java:
##########
@@ -285,6 +285,13 @@ private Configs() {}
.booleanConf()
.createWithDefault(false);
+ public static final ConfigEntry<String> AUTHORIZATION_IMPL =
+ new ConfigBuilder("gravitino.authorization.impl")
+ .doc("Metadata authorization implement")
+ .version(ConfigConstants.VERSION_1_0_0)
+ .stringConf()
+ .createWithDefault("PassThrough");
Review Comment:
You should better to use class name and use reflection to create authorizer.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7449]feat(authz): Support Catalog Authorization [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7450:
URL: https://github.com/apache/gravitino/pull/7450#discussion_r2174382504
##########
core/src/main/java/org/apache/gravitino/Configs.java:
##########
@@ -285,6 +285,13 @@ private Configs() {}
.booleanConf()
.createWithDefault(false);
+ public static final ConfigEntry<String> AUTHORIZATION_IMPL =
+ new ConfigBuilder("gravitino.authorization.impl")
+ .doc("Metadata authorization implement")
Review Comment:
`implementation`
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org