Pre Merge pull request !117 from jackie/master
commit
d3318a7633
|
|
@ -24,12 +24,15 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
import org.springframework.web.util.pattern.PathPattern;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 自定义的 Spring Security 配置适配器实现
|
||||
|
|
@ -161,10 +164,21 @@ public class YudaoWebSecurityConfigurerAdapter {
|
|||
if (!handlerMethod.hasMethodAnnotation(PermitAll.class)) {
|
||||
continue;
|
||||
}
|
||||
if (entry.getKey().getPatternsCondition() == null) {
|
||||
|
||||
Set<String> urls = new HashSet<>();
|
||||
|
||||
if (null != entry.getKey().getPatternsCondition()) {
|
||||
urls.addAll( entry.getKey().getPatternsCondition().getPatterns());
|
||||
}
|
||||
//如果请求路径与控制器方法的路径模式匹配,但请求方法不匹配,则getPatternsCondition()会返回false,而getPathPatternsCondition()仍然会返回true
|
||||
if (null != entry.getKey().getPathPatternsCondition()){
|
||||
urls.addAll(entry.getKey().getPathPatternsCondition().getPatterns().stream().map(PathPattern::getPatternString).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
if (urls.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
Set<String> urls = entry.getKey().getPatternsCondition().getPatterns();
|
||||
|
||||
// 特殊:使用 @RequestMapping 注解,并且未写 method 属性,此时认为都需要免登录
|
||||
Set<RequestMethod> methods = entry.getKey().getMethodsCondition().getMethods();
|
||||
if (CollUtil.isEmpty(methods)) { //
|
||||
|
|
|
|||
Loading…
Reference in New Issue