|
@@ -4,10 +4,12 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
|
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
|
import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
|
|
import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
|
|
import org.apache.shiro.mgt.DefaultSubjectDAO;
|
|
import org.apache.shiro.mgt.DefaultSubjectDAO;
|
|
|
|
+import org.apache.shiro.mgt.RememberMeManager;
|
|
import org.apache.shiro.mgt.SecurityManager;
|
|
import org.apache.shiro.mgt.SecurityManager;
|
|
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
|
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
|
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
|
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
|
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
|
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
|
|
|
+import org.apache.shiro.web.mgt.CookieRememberMeManager;
|
|
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
|
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
|
import org.crazycake.shiro.*;
|
|
import org.crazycake.shiro.*;
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
@@ -17,17 +19,15 @@ import org.jeecg.config.shiro.filters.CustomShiroFilterFactoryBean;
|
|
import org.jeecg.config.shiro.filters.JwtFilter;
|
|
import org.jeecg.config.shiro.filters.JwtFilter;
|
|
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
|
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.beans.factory.config.BeanDefinition;
|
|
|
|
|
|
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
-import org.springframework.context.annotation.*;
|
|
|
|
-import org.springframework.core.annotation.AnnotationUtils;
|
|
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
|
+import org.springframework.context.annotation.DependsOn;
|
|
import org.springframework.core.env.Environment;
|
|
import org.springframework.core.env.Environment;
|
|
-import org.springframework.core.type.filter.AnnotationTypeFilter;
|
|
|
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
|
-import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.filter.DelegatingFilterProxy;
|
|
import org.springframework.web.filter.DelegatingFilterProxy;
|
|
import redis.clients.jedis.HostAndPort;
|
|
import redis.clients.jedis.HostAndPort;
|
|
import redis.clients.jedis.JedisCluster;
|
|
import redis.clients.jedis.JedisCluster;
|
|
@@ -35,7 +35,6 @@ import redis.clients.jedis.JedisCluster;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.DispatcherType;
|
|
import javax.servlet.DispatcherType;
|
|
import javax.servlet.Filter;
|
|
import javax.servlet.Filter;
|
|
-import java.lang.reflect.Method;
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -232,6 +231,7 @@ public class ShiroConfig {
|
|
@Bean("securityManager")
|
|
@Bean("securityManager")
|
|
public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
|
|
public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
|
|
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
|
|
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
|
|
|
|
+ securityManager.setRememberMeManager(rememberMeManager());
|
|
securityManager.setRealm(myRealm);
|
|
securityManager.setRealm(myRealm);
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -295,6 +295,13 @@ public class ShiroConfig {
|
|
redisCacheManager.setExpire(200000);
|
|
redisCacheManager.setExpire(200000);
|
|
return redisCacheManager;
|
|
return redisCacheManager;
|
|
}
|
|
}
|
|
|
|
+ @Bean
|
|
|
|
+ public RememberMeManager rememberMeManager() {
|
|
|
|
+ CookieRememberMeManager manager = new CookieRememberMeManager();
|
|
|
|
+ // 设置固定密钥(Base64 编码格式)
|
|
|
|
+ manager.setCipherKey(Base64.getDecoder().decode("rU35IxMwkUE8b3dv/5C9sg=="));
|
|
|
|
+ return manager;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* RedisConfig在项目starter项目中
|
|
* RedisConfig在项目starter项目中
|