Skip to content

Commit

Permalink
🔖 Releasing / Version tags. 3.7.0-JDK8
Browse files Browse the repository at this point in the history
  • Loading branch information
lbw committed Aug 17, 2023
1 parent cc43baa commit 80adb67
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@

package com.pig4cloud.pig.common.security.component;

import cn.hutool.core.util.StrUtil;
import com.pig4cloud.pig.common.core.constant.SecurityConstants;
import com.pig4cloud.pig.common.security.annotation.Inner;
import javax.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.security.access.AccessDeniedException;

import javax.servlet.http.HttpServletRequest;

/**
* @author lengleng
* @date 2022-06-04
Expand All @@ -46,13 +47,12 @@ public class PigSecurityInnerAspect implements Ordered {
@Before("@within(inner) || @annotation(inner)")
public void around(JoinPoint point, Inner inner) {
// 实际注入的inner实体由表达式后一个注解决定,即是方法上的@Inner注解实体,若方法上无@Inner注解,则获取类上的
// 这段代码没有意义,拦截的就是@Inner注解,怎么会为null呢
// if (inner == null) {
// Class<?> clazz = point.getTarget().getClass();
// inner = AnnotationUtils.findAnnotation(clazz, Inner.class);
// }
if (inner == null) {
Class<?> clazz = point.getTarget().getClass();
inner = AnnotationUtils.findAnnotation(clazz, Inner.class);
}
String header = request.getHeader(SecurityConstants.FROM);
if (inner.value() && !SecurityConstants.FROM_IN.equals(header)) {
if (inner.value() && !StrUtil.equals(SecurityConstants.FROM_IN, header)) {
log.warn("访问接口 {} 没有权限", point.getSignature().getName());
throw new AccessDeniedException("Access is denied");
}
Expand Down

0 comments on commit 80adb67

Please sign in to comment.