shiro使用started依赖;
This commit is contained in:
parent
0dfbee487a
commit
b59d4219d2
11
pom.xml
11
pom.xml
|
|
@ -64,14 +64,7 @@
|
||||||
<!--Shiro核心框架 -->
|
<!--Shiro核心框架 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.shiro</groupId>
|
<groupId>org.apache.shiro</groupId>
|
||||||
<artifactId>shiro-core</artifactId>
|
<artifactId>shiro-spring-boot-starter</artifactId>
|
||||||
<version>${shiro.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Shiro使用Srping框架 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.shiro</groupId>
|
|
||||||
<artifactId>shiro-spring</artifactId>
|
|
||||||
<version>${shiro.version}</version>
|
<version>${shiro.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
@ -81,7 +74,7 @@
|
||||||
<artifactId>shiro-ehcache</artifactId>
|
<artifactId>shiro-ehcache</artifactId>
|
||||||
<version>${shiro.version}</version>
|
<version>${shiro.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- thymeleaf模板引擎和shiro框架的整合 -->
|
<!-- thymeleaf模板引擎和shiro框架的整合 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.theborakompanioni</groupId>
|
<groupId>com.github.theborakompanioni</groupId>
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,8 @@ spring:
|
||||||
max-idle: 8
|
max-idle: 8
|
||||||
min-idle: 2
|
min-idle: 2
|
||||||
max-wait: -1
|
max-wait: -1
|
||||||
|
application:
|
||||||
|
name: framework
|
||||||
# Shiro
|
# Shiro
|
||||||
shiro:
|
shiro:
|
||||||
user:
|
user:
|
||||||
|
|
@ -146,10 +148,10 @@ swagger:
|
||||||
cache:
|
cache:
|
||||||
names:
|
names:
|
||||||
sys_dict_type:
|
sys_dict_type:
|
||||||
ttl: PT1M
|
ttl: PT10M
|
||||||
sys_user:
|
sys_user:
|
||||||
ttl: PT1M
|
ttl: PT10M
|
||||||
sys_post:
|
sys_post:
|
||||||
ttl: PT1M
|
ttl: PT10M
|
||||||
sys_role:
|
sys_role:
|
||||||
ttl: PT1M
|
ttl: PT10M
|
||||||
|
|
@ -32,15 +32,19 @@
|
||||||
<!--Shiro核心框架 -->
|
<!--Shiro核心框架 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.shiro</groupId>
|
<groupId>org.apache.shiro</groupId>
|
||||||
<artifactId>shiro-core</artifactId>
|
<artifactId>shiro-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Shiro使用EhCache缓存框架 -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.shiro</groupId>
|
<groupId>org.apache.shiro</groupId>
|
||||||
<artifactId>shiro-ehcache</artifactId>
|
<artifactId>shiro-ehcache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.theborakompanioni</groupId>
|
||||||
|
<artifactId>thymeleaf-extras-shiro</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 自定义验证注解 -->
|
<!-- 自定义验证注解 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.validation</groupId>
|
<groupId>javax.validation</groupId>
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,6 @@
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Shiro使用Spring框架 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.shiro</groupId>
|
|
||||||
<artifactId>shiro-spring</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- thymeleaf模板引擎和shiro框架的整合 -->
|
<!-- thymeleaf模板引擎和shiro框架的整合 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.theborakompanioni</groupId>
|
<groupId>com.github.theborakompanioni</groupId>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import com.ruoyi.common.properties.CacheProperties;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
|
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -27,7 +28,7 @@ import java.util.Map;
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@Configuration
|
@Configuration
|
||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||||
public class CacheConfig {
|
public class CacheConfig extends CachingConfigurerSupport {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisConnectionFactory factory;
|
private RedisConnectionFactory factory;
|
||||||
|
|
@ -42,6 +43,7 @@ public class CacheConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@Override
|
||||||
public CacheManager cacheManager() {
|
public CacheManager cacheManager() {
|
||||||
RedisCacheConfiguration defaultConfiguration = RedisCacheConfiguration.defaultCacheConfig()
|
RedisCacheConfiguration defaultConfiguration = RedisCacheConfiguration.defaultCacheConfig()
|
||||||
.disableCachingNullValues()
|
.disableCachingNullValues()
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.Filter;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.shiro.cache.ehcache.EhCacheManager;
|
import org.apache.shiro.cache.ehcache.EhCacheManager;
|
||||||
import org.apache.shiro.codec.Base64;
|
import org.apache.shiro.codec.Base64;
|
||||||
|
|
@ -17,6 +18,7 @@ import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||||
import org.apache.shiro.web.mgt.CookieRememberMeManager;
|
import org.apache.shiro.web.mgt.CookieRememberMeManager;
|
||||||
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
||||||
import org.apache.shiro.web.servlet.SimpleCookie;
|
import org.apache.shiro.web.servlet.SimpleCookie;
|
||||||
|
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
@ -34,15 +36,16 @@ import com.ruoyi.framework.shiro.web.filter.sync.SyncOnlineSessionFilter;
|
||||||
import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager;
|
import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager;
|
||||||
import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler;
|
import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler;
|
||||||
import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
|
import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限配置加载
|
* 权限配置加载
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ShiroConfig
|
public class ShiroConfig {
|
||||||
{
|
|
||||||
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -127,17 +130,13 @@ public class ShiroConfig
|
||||||
* 缓存管理器 使用Ehcache实现
|
* 缓存管理器 使用Ehcache实现
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public EhCacheManager getEhCacheManager()
|
public EhCacheManager getEhCacheManager() {
|
||||||
{
|
|
||||||
net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("ruoyi");
|
net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("ruoyi");
|
||||||
EhCacheManager em = new EhCacheManager();
|
EhCacheManager em = new EhCacheManager();
|
||||||
if (StringUtils.isNull(cacheManager))
|
if (StringUtils.isNull(cacheManager)) {
|
||||||
{
|
|
||||||
em.setCacheManager(new net.sf.ehcache.CacheManager(getCacheManagerConfigFileInputStream()));
|
em.setCacheManager(new net.sf.ehcache.CacheManager(getCacheManagerConfigFileInputStream()));
|
||||||
return em;
|
return em;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
em.setCacheManager(cacheManager);
|
em.setCacheManager(cacheManager);
|
||||||
return em;
|
return em;
|
||||||
}
|
}
|
||||||
|
|
@ -146,24 +145,18 @@ public class ShiroConfig
|
||||||
/**
|
/**
|
||||||
* 返回配置文件流 避免ehcache配置文件一直被占用,无法完全销毁项目重新部署
|
* 返回配置文件流 避免ehcache配置文件一直被占用,无法完全销毁项目重新部署
|
||||||
*/
|
*/
|
||||||
protected InputStream getCacheManagerConfigFileInputStream()
|
protected InputStream getCacheManagerConfigFileInputStream() {
|
||||||
{
|
|
||||||
String configFile = "classpath:ehcache/ehcache-shiro.xml";
|
String configFile = "classpath:ehcache/ehcache-shiro.xml";
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
inputStream = ResourceUtils.getInputStreamForPath(configFile);
|
inputStream = ResourceUtils.getInputStreamForPath(configFile);
|
||||||
byte[] b = IOUtils.toByteArray(inputStream);
|
byte[] b = IOUtils.toByteArray(inputStream);
|
||||||
InputStream in = new ByteArrayInputStream(b);
|
InputStream in = new ByteArrayInputStream(b);
|
||||||
return in;
|
return in;
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
throw new ConfigurationException(
|
throw new ConfigurationException(
|
||||||
"Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e);
|
"Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e);
|
||||||
}
|
} finally {
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtils.closeQuietly(inputStream);
|
IOUtils.closeQuietly(inputStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -172,8 +165,7 @@ public class ShiroConfig
|
||||||
* 自定义Realm
|
* 自定义Realm
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public UserRealm userRealm(EhCacheManager cacheManager)
|
public UserRealm userRealm(EhCacheManager cacheManager) {
|
||||||
{
|
|
||||||
UserRealm userRealm = new UserRealm();
|
UserRealm userRealm = new UserRealm();
|
||||||
userRealm.setCacheManager(cacheManager);
|
userRealm.setCacheManager(cacheManager);
|
||||||
return userRealm;
|
return userRealm;
|
||||||
|
|
@ -183,8 +175,7 @@ public class ShiroConfig
|
||||||
* 自定义sessionDAO会话
|
* 自定义sessionDAO会话
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public OnlineSessionDAO sessionDAO()
|
public OnlineSessionDAO sessionDAO() {
|
||||||
{
|
|
||||||
OnlineSessionDAO sessionDAO = new OnlineSessionDAO();
|
OnlineSessionDAO sessionDAO = new OnlineSessionDAO();
|
||||||
return sessionDAO;
|
return sessionDAO;
|
||||||
}
|
}
|
||||||
|
|
@ -193,8 +184,7 @@ public class ShiroConfig
|
||||||
* 自定义sessionFactory会话
|
* 自定义sessionFactory会话
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public OnlineSessionFactory sessionFactory()
|
public OnlineSessionFactory sessionFactory() {
|
||||||
{
|
|
||||||
OnlineSessionFactory sessionFactory = new OnlineSessionFactory();
|
OnlineSessionFactory sessionFactory = new OnlineSessionFactory();
|
||||||
return sessionFactory;
|
return sessionFactory;
|
||||||
}
|
}
|
||||||
|
|
@ -203,8 +193,7 @@ public class ShiroConfig
|
||||||
* 会话管理器
|
* 会话管理器
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public OnlineWebSessionManager sessionManager()
|
public OnlineWebSessionManager sessionManager() {
|
||||||
{
|
|
||||||
OnlineWebSessionManager manager = new OnlineWebSessionManager();
|
OnlineWebSessionManager manager = new OnlineWebSessionManager();
|
||||||
// 加入缓存管理器
|
// 加入缓存管理器
|
||||||
manager.setCacheManager(getEhCacheManager());
|
manager.setCacheManager(getEhCacheManager());
|
||||||
|
|
@ -229,8 +218,7 @@ public class ShiroConfig
|
||||||
* 安全管理器
|
* 安全管理器
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityManager securityManager(UserRealm userRealm)
|
public DefaultWebSecurityManager securityManager(UserRealm userRealm) {
|
||||||
{
|
|
||||||
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
|
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
|
||||||
// 设置realm.
|
// 设置realm.
|
||||||
securityManager.setRealm(userRealm);
|
securityManager.setRealm(userRealm);
|
||||||
|
|
@ -246,8 +234,7 @@ public class ShiroConfig
|
||||||
/**
|
/**
|
||||||
* 退出过滤器
|
* 退出过滤器
|
||||||
*/
|
*/
|
||||||
public LogoutFilter logoutFilter()
|
public LogoutFilter logoutFilter() {
|
||||||
{
|
|
||||||
LogoutFilter logoutFilter = new LogoutFilter();
|
LogoutFilter logoutFilter = new LogoutFilter();
|
||||||
logoutFilter.setLoginUrl(loginUrl);
|
logoutFilter.setLoginUrl(loginUrl);
|
||||||
return logoutFilter;
|
return logoutFilter;
|
||||||
|
|
@ -257,8 +244,7 @@ public class ShiroConfig
|
||||||
* Shiro过滤器配置
|
* Shiro过滤器配置
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager)
|
public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) {
|
||||||
{
|
|
||||||
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
|
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
|
||||||
// Shiro的核心安全接口,这个属性是必须的
|
// Shiro的核心安全接口,这个属性是必须的
|
||||||
shiroFilterFactoryBean.setSecurityManager(securityManager);
|
shiroFilterFactoryBean.setSecurityManager(securityManager);
|
||||||
|
|
@ -308,8 +294,7 @@ public class ShiroConfig
|
||||||
* 自定义在线用户处理过滤器
|
* 自定义在线用户处理过滤器
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public OnlineSessionFilter onlineSessionFilter()
|
public OnlineSessionFilter onlineSessionFilter() {
|
||||||
{
|
|
||||||
OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter();
|
OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter();
|
||||||
onlineSessionFilter.setLoginUrl(loginUrl);
|
onlineSessionFilter.setLoginUrl(loginUrl);
|
||||||
return onlineSessionFilter;
|
return onlineSessionFilter;
|
||||||
|
|
@ -319,8 +304,7 @@ public class ShiroConfig
|
||||||
* 自定义在线用户同步过滤器
|
* 自定义在线用户同步过滤器
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public SyncOnlineSessionFilter syncOnlineSessionFilter()
|
public SyncOnlineSessionFilter syncOnlineSessionFilter() {
|
||||||
{
|
|
||||||
SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter();
|
SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter();
|
||||||
return syncOnlineSessionFilter;
|
return syncOnlineSessionFilter;
|
||||||
}
|
}
|
||||||
|
|
@ -329,8 +313,7 @@ public class ShiroConfig
|
||||||
* 自定义验证码过滤器
|
* 自定义验证码过滤器
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public CaptchaValidateFilter captchaValidateFilter()
|
public CaptchaValidateFilter captchaValidateFilter() {
|
||||||
{
|
|
||||||
CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter();
|
CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter();
|
||||||
captchaValidateFilter.setCaptchaEnabled(captchaEnabled);
|
captchaValidateFilter.setCaptchaEnabled(captchaEnabled);
|
||||||
captchaValidateFilter.setCaptchaType(captchaType);
|
captchaValidateFilter.setCaptchaType(captchaType);
|
||||||
|
|
@ -340,8 +323,7 @@ public class ShiroConfig
|
||||||
/**
|
/**
|
||||||
* cookie 属性设置
|
* cookie 属性设置
|
||||||
*/
|
*/
|
||||||
public SimpleCookie rememberMeCookie()
|
public SimpleCookie rememberMeCookie() {
|
||||||
{
|
|
||||||
SimpleCookie cookie = new SimpleCookie("rememberMe");
|
SimpleCookie cookie = new SimpleCookie("rememberMe");
|
||||||
cookie.setDomain(domain);
|
cookie.setDomain(domain);
|
||||||
cookie.setPath(path);
|
cookie.setPath(path);
|
||||||
|
|
@ -353,8 +335,7 @@ public class ShiroConfig
|
||||||
/**
|
/**
|
||||||
* 记住我
|
* 记住我
|
||||||
*/
|
*/
|
||||||
public CookieRememberMeManager rememberMeManager()
|
public CookieRememberMeManager rememberMeManager() {
|
||||||
{
|
|
||||||
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
|
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
|
||||||
cookieRememberMeManager.setCookie(rememberMeCookie());
|
cookieRememberMeManager.setCookie(rememberMeCookie());
|
||||||
cookieRememberMeManager.setCipherKey(Base64.decode(cipherKey));
|
cookieRememberMeManager.setCipherKey(Base64.decode(cipherKey));
|
||||||
|
|
@ -364,8 +345,7 @@ public class ShiroConfig
|
||||||
/**
|
/**
|
||||||
* 同一个用户多设备登录限制
|
* 同一个用户多设备登录限制
|
||||||
*/
|
*/
|
||||||
public KickoutSessionFilter kickoutSessionFilter()
|
public KickoutSessionFilter kickoutSessionFilter() {
|
||||||
{
|
|
||||||
KickoutSessionFilter kickoutSessionFilter = new KickoutSessionFilter();
|
KickoutSessionFilter kickoutSessionFilter = new KickoutSessionFilter();
|
||||||
kickoutSessionFilter.setCacheManager(getEhCacheManager());
|
kickoutSessionFilter.setCacheManager(getEhCacheManager());
|
||||||
kickoutSessionFilter.setSessionManager(sessionManager());
|
kickoutSessionFilter.setSessionManager(sessionManager());
|
||||||
|
|
@ -382,8 +362,7 @@ public class ShiroConfig
|
||||||
* thymeleaf模板引擎和shiro框架的整合
|
* thymeleaf模板引擎和shiro框架的整合
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public ShiroDialect shiroDialect()
|
public ShiroDialect shiroDialect() {
|
||||||
{
|
|
||||||
return new ShiroDialect();
|
return new ShiroDialect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -391,11 +370,21 @@ public class ShiroConfig
|
||||||
* 开启Shiro注解通知器
|
* 开启Shiro注解通知器
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(
|
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor( @Qualifier("securityManager") SecurityManager securityManager) {
|
||||||
@Qualifier("securityManager") SecurityManager securityManager)
|
|
||||||
{
|
|
||||||
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
|
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
|
||||||
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
|
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
|
||||||
return authorizationAttributeSourceAdvisor;
|
return authorizationAttributeSourceAdvisor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下面的代码是添加注解支持
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
|
||||||
|
DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
|
||||||
|
// 强制使用cglib,防止重复代理和可能引起代理出错的问题
|
||||||
|
// https://zhuanlan.zhihu.com/p/29161098
|
||||||
|
defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
|
||||||
|
return defaultAdvisorAutoProxyCreator;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue