|
|
@@ -4,8 +4,10 @@ import java.util.LinkedHashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import org.apache.shiro.mgt.SecurityManager;
|
|
|
+import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
|
|
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
|
|
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
|
|
+import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
@@ -20,6 +22,21 @@ public class ShiroConfig {
|
|
|
private String managerPath;
|
|
|
|
|
|
@Bean
|
|
|
+ public AuthorizationAttributeSourceAdvisor getAuthorizationAttributeSourceAdvisor(
|
|
|
+ DefaultWebSecurityManager securityManager) {
|
|
|
+ AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
|
|
|
+ advisor.setSecurityManager(securityManager);
|
|
|
+ return advisor;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public DefaultAdvisorAutoProxyCreator getDefaultAdvisorAutoProxyCreator() {
|
|
|
+ DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
|
|
|
+ autoProxyCreator.setProxyTargetClass(true);
|
|
|
+ return autoProxyCreator;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
|
|
|
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
|
|
|
// 必须设置 SecurityManager
|
|
|
@@ -65,4 +82,4 @@ public class ShiroConfig {
|
|
|
public BaseAuthRealm customRealm() {
|
|
|
return new BaseAuthRealm();
|
|
|
}
|
|
|
-}
|
|
|
+}
|