zhangjidi2016 commented on a change in pull request #6: URL: https://github.com/apache/rocketmq-dashboard/pull/6#discussion_r690923485
########## File path: src/main/java/org/apache/rocketmq/dashboard/permisssion/PermissionAspect.java ########## @@ -0,0 +1,82 @@ +/* + * 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.rocketmq.dashboard.permisssion; + +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import org.apache.rocketmq.dashboard.config.RMQConfigure; +import org.apache.rocketmq.dashboard.exception.ServiceException; +import org.apache.rocketmq.dashboard.model.UserInfo; +import org.apache.rocketmq.dashboard.service.PermissionService; +import org.apache.rocketmq.dashboard.util.WebUtil; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +@Aspect +@Component +public class PermissionAspect { + + public static final String ORDINARY = "ordinary"; + public static final String ADMIN = "admin"; + + @Resource + private RMQConfigure configure; + + @Resource + private PermissionService permissionService; + + /** + * @Permission can be applied to the Controller class to implement Permission verification on all methods in the class + * can also be applied to methods in a class for fine control + */ + @Pointcut("@annotation(org.apache.rocketmq.dashboard.permisssion.Permission) || @within(org.apache.rocketmq.dashboard.permisssion.Permission)") + private void permission() { Review comment: Yes,it can work,@within - limits matching to join points within types that have the given annotation (the execution of methods declared in types with the given annotation when using Spring AOP). -- 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]
