优化配置参数的名字和日志输出级别

pull/291/head
天天向上 3 years ago
parent 47993ef573
commit e36b3642da

@ -21,7 +21,7 @@ import java.lang.reflect.Method;
*/
@Aspect
@Component
@ConditionalOnProperty(prefix = "security.aspect", name = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(prefix = "security.annotation", name = "enabled", havingValue = "true", matchIfMissing = true)
public class PreAuthorizeAspect
{
/**

@ -19,18 +19,21 @@ import java.util.*;
/**
* =====================================使=======================================
*
*
*
* 使
* 1security.aspect.enabled: false
* 2routePrefix: : /auth
* 1security.annotation.enabled: false
* 2pathPrefix: : /auth
* 3security.gateway.enabled: true
*
* redis便
*/
@ConditionalOnProperty(prefix = "security.gateway", name = "enabled", havingValue = "true")
@ConditionalOnProperty(prefix = "security.annotation", name = "enabled", havingValue = "false")
public class PathPermissionMappingConfig {
@Value("${routePrefix}")
private String routePrefix;
/**
* predicatesPath /system
*/
@Value("${pathPrefix}")
private String pathPrefix;
@PostConstruct
public PathPermissionMappingConfig execute() {
@ -85,7 +88,7 @@ public class PathPermissionMappingConfig {
private void addPathPermsMap(String perms, Map<String, String> pathPermsMap, Set<RequestMethod> methods, Set<String> patternValues) {
for (RequestMethod method : methods) {
for (String patternValue : patternValues) {
String key = routePrefix + patternValue + "_" + method.name();
String key = pathPrefix + patternValue + "_" + method.name();
pathPermsMap.put(key, perms);
}
}

@ -133,21 +133,21 @@ public class AuthFilter implements GlobalFilter, Ordered
if(!rolePerms.isEmpty()) {
if(rolePerms.contains(SecurityConstants.ROLE_ANON)) {
log.info("允许访问公共权限:{}{}", api, rolePerms);
log.debug("允许访问公共权限:{}{}", api, rolePerms);
return true;
}
rolePerms = rolePerms.stream().map(item -> item.substring(SecurityConstants.ROLE_PREFIX.length())).collect(Collectors.toSet());
// 求交集
rolePerms.retainAll(roles);
if(!rolePerms.isEmpty()) {
log.info("允许访问角色权限:{} {}", api, rolePerms);
log.debug("允许访问角色权限:{} {}", api, rolePerms);
return true;
}
}
// 求交集
matchedPerms.retainAll(permissions);
if(!matchedPerms.isEmpty()) {
log.info("允许访问资源权限:{}{}", api, matchedPerms);
log.debug("允许访问资源权限:{}{}", api, matchedPerms);
return true;
}
}

Loading…
Cancel
Save