亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

java - shiro anon 不生效

瀏覽:71日期: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
相關文章:
主站蜘蛛池模板: 口国产成人高清在线播放 | 大片免费播放 | 日本久久网站 | 精品视频免费在线 | 国产乱人伦精品一区二区 | 亚洲国产欧美日韩第一香蕉 | 成人毛片在线 | 狠狠色丁香婷综合久久 | 美女一级大黄录像一片 | 青青黄色 | 亚洲黄色在线观看视频 | 国产无遮挡又黄又爽在线视频 | 国产精品_国产精品_国产精品 | 免费永久在线观看黄网 | 尤物精品在线观看 | 黄在线观看 | 国产精品二区三区 | 免费久草视频 | 91全国探花精品正在播放 | 久久国产视频一区 | 国产成+人+亚洲+欧美综合 | 中国黄色片视频 | 国产成人精品久久免费动漫 | 永久在线观看www免费视频 | 黄色毛片免费看 | 亚洲香蕉综合在人在线时看 | 国产乱码精品一区二区三区中 | 玖玖爱在线播放 | 黄色大片在线观看 | 看黄色录像一级片 | 免费国产成人午夜在线观看 | 在线欧美69v免费观看视频 | 免费国产99久久久香蕉 | 欧美日韩一区二区三区自拍 | 精品一区二区三区在线视频 | 精品自在线 | 伊人久久大香线蕉精品哪里 | 日韩精品一区二区三区在线观看l | 好色婷婷 | 国产久草视频在线 | 香蕉视频免费看 |