hdygxsj commented on code in PR #7258:
URL: https://github.com/apache/gravitino/pull/7258#discussion_r2115224881
##########
server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java:
##########
@@ -66,7 +81,89 @@ private static class MetadataAuthorizationMethodInterceptor
implements MethodInt
*/
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
- throw new UnsupportedOperationException();
+ 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<MetadataObject.Type, NameIdentifier> metadataContext =
+ getMetadataContext(parameters, args);
+ AuthorizationExpressionEvaluator authorizationExpressionEvaluator =
+ new AuthorizationExpressionEvaluator(expression);
+ boolean authorizeResult =
authorizationExpressionEvaluator.evaluate(metadataContext);
+ if (!authorizeResult) {
+ return Utils.internalError("Can not access metadata.");
+ }
+ }
+ return methodInvocation.proceed();
+ }
+
+ private Map<MetadataObject.Type, NameIdentifier> getMetadataContext(
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]