国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

java - shiro anon 不生效

瀏覽:91日期:2023-12-25 11:23:16

問題描述

在使用springboot整合shiro的過程中,希望靜態資源資源不受shiro過濾器‘authc’攔截,于是定義了“anon”,測試發現根本不生效,靜態資源路徑下的資源(如/js/**)依舊會被攔截并重定向到/login,以下是我的shiro javaconfig

ShiroConfig.java

@Configurationpublic class ShiroConfig { @Value('${shiro.credentialsMatcher.hashIterations}') private int hashIterations; @Value('${shiro.credentialsMatcher.storedCredentialsHexEncoded}') private boolean storedCredentialsHexEncoded; @Configuration protected static class Processor {@Beanpublic LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { return new LifecycleBeanPostProcessor();}@Bean@DependsOn('lifecycleBeanPostProcessor')public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { final DefaultAdvisorAutoProxyCreator proxyCreator = new DefaultAdvisorAutoProxyCreator(); proxyCreator.setProxyTargetClass(true); return proxyCreator;}@Beanpublic AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) { AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor(); advisor.setSecurityManager(securityManager); return advisor;} } @Bean('credentialsMatcher') public HashedCredentialsMatcher getCredentialsMatcher() {HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher();credentialsMatcher.setHashAlgorithmName('MD5');credentialsMatcher.setHashIterations(hashIterations);credentialsMatcher.setStoredCredentialsHexEncoded(storedCredentialsHexEncoded);return credentialsMatcher; } @Bean(name = 'shiroEhcacheManager') @DependsOn('lifecycleBeanPostProcessor') public EhCacheManager getEhCacheManager() {EhCacheManager em = new EhCacheManager();em.setCacheManagerConfigFile('classpath:conf/shiro-ehcache.xml');return em; } @Bean('userRealm') @DependsOn('lifecycleBeanPostProcessor') public UserRealm getUserRealm(HashedCredentialsMatcher credentialsMatcher) {UserRealm userRealm = new UserRealm();userRealm.setCachingEnabled(false);userRealm.setCredentialsMatcher(credentialsMatcher);return userRealm; } @Bean('securityManager') public DefaultWebSecurityManager getSecurityManager(UserRealm userRealm) {DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();securityManager.setCacheManager(getEhCacheManager());securityManager.setRealm(userRealm);return securityManager; } @Bean('shiroFilter') public ShiroFilterFactoryBean getShiroFilter(DefaultWebSecurityManager securityManager) {ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();shiroFilterFactoryBean.setSecurityManager(securityManager);Map<String, String> filterChainDefinitionMap = Maps.newHashMap();filterChainDefinitionMap.put('/css/**', 'anon');filterChainDefinitionMap.put('/img/**', 'anon');filterChainDefinitionMap.put('/js/**', 'anon');filterChainDefinitionMap.put('/plugins/**', 'anon');filterChainDefinitionMap.put('/error/**', 'anon');filterChainDefinitionMap.put('/login', 'authc');filterChainDefinitionMap.put('/logout', 'logout');filterChainDefinitionMap.put('/**', 'authc');shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);shiroFilterFactoryBean.setLoginUrl('/login');shiroFilterFactoryBean.setSuccessUrl('/');shiroFilterFactoryBean.setUnauthorizedUrl('/login');return shiroFilterFactoryBean; }}

請指正

問題解答

回答1:

解決了,filterChainDefinitionMap應當為LinkedHashMap

標簽: java
相關文章:
主站蜘蛛池模板: 成人在线免费播放 | 欧美成人伊人十综合色 | 成 人免费va视频 | 黄a在线观看 | 国产手机在线精品 | wwwxx在线| 欧美日韩偷拍自拍 | 香焦视频在线观看黄 | 天天爽夜夜操 | 日本免费一区二区三区看片 | 亚洲一区二区三区免费在线观看 | v片视频| 亚洲波多野结衣日韩在线 | 91福利网| 美女三级毛片 | 日本护士一级毛片在线播放 | 一级特黄爽大片刺激 | 亚洲国产91| 黄色成人毛片 | 欧美第一精品 | www.91香蕉视频 | 欧美日韩精品一区三区 | 在线观看欧美一区 | 久久久久在线观看 | 不卡一区二区在线 | 97在线碰碰观看免费高清 | 国产在线精品观看一区 | 久久高清精品 | 国产精品久久一区 | 国产天堂 | 欧美三级毛片 | 亚洲毛片在线免费观看 | 午夜香港三级a三级三点 | 国产精品久久永久免费 | 欧美日韩视频一区二区在线观看 | 免费看美女午夜大片 | 在线观看精品视频网站www | 美国三级网 | 久久不见久久见免费影院www日本 | 欧美ab| 国产乱子伦露脸对白在线小说 |