This commit is contained in:
LuoYe_MyWork 2020-08-21 17:15:48 +08:00
parent d51fbe02a8
commit b009fb792a
3 changed files with 7 additions and 7 deletions

View File

@ -25,18 +25,18 @@ import java.util.Iterator;
public class UrlAccessDecisionManager implements AccessDecisionManager {
@Override
public void decide(Authentication authentication, Object o, Collection<ConfigAttribute> collection) throws AccessDeniedException, InsufficientAuthenticationException {
log.debug("进入权限判断!");
log.info("进入权限判断!");
if (collection == null) {
return;
}
log.debug("object is a URL. {}", o.toString());
log.info("object is a URL. {}", o.toString());
//所请求的资源拥有的权限(一个资源对多个权限)
Iterator<ConfigAttribute> iterator = collection.iterator();
while (iterator.hasNext()) {
ConfigAttribute configAttribute = iterator.next();
//访问所请求资源所需要的权限
String needPermission = configAttribute.getAttribute();
log.debug("访问 " + o.toString() + " 需要的权限是:" + needPermission);
log.info("访问 " + o.toString() + " 需要的权限是:" + needPermission);
if (needPermission == null) {
break;
}

View File

@ -36,6 +36,8 @@ public class UrlInvocationSecurityMetadataSourceService implements FilterInvocat
permissions.put("/admin/**", "admin");
permissions.put("/**", "user");
permissions.put("/auth2/**", "ROLE_ANONYMOUS");
permissions.put("/error", "ROLE_ANONYMOUS");
Iterator<Map.Entry<String, String>> iterator = permissions.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> next = iterator.next();

View File

@ -4,12 +4,10 @@ import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
import io.qyi.e5.util.SpringUtil;
import io.qyi.e5.util.redis.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
@ -52,9 +50,9 @@ public class LinkTokenAuthenticationFilter extends OncePerRequestFilter {
log.info("--------------Token鉴权---------------");
/*设置跨域*/
HttpServletResponse response = httpServletResponse;
response.setHeader("Access-Control-Allow-Origin", "e5.qyi.io");
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST");
response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST,OPTIONS");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, token");
/*如果是OPTIONS则结束请求*/