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

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

java - shiro anon 不生效

瀏覽:62日期: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
相關文章:
主站蜘蛛池模板: 久久伊人热老鸭窝 | 国产精品v欧美精品∨日韩 国产精品www | 伊人网影院 | 午夜精品久久久久久 | 国产成人在线网址 | 亚洲综合色婷婷中文字幕 | 日韩视频免费在线观看 | 性xxxxxxx18老师 | 国产日韩久久久精品影院首页 | 全色黄大色大片免费久久老太 | 国产伦精品一区二区三区免 | 久草在线新首页 | baoyu122.永久免费视频 | 给个网站可以在线观看你懂的 | 九九热精品视频在线观看 | 国产美女啪 | 欧美三级在线观看播放 | 亚洲成人网在线观看 | 欧美黄色视屏 | 青青在线香蕉精品视频免费看 | 日本中文字幕不卡在线一区二区 | 欧美亚洲综合在线观看 | 国产精品成人一区二区1 | 亚洲人成网站在线观看青青 | 国产成人精品午夜 | 亚洲视频免费在线 | a级做爰毛片视频免费看 | 在线免费观看精品 | 可以看黄色的网址 | 国产免费一区二区三区在线观看 | 亚洲午夜久久影院 | 手机看片在线精品观看 | 亚洲精品国产成人一区二区 | 精品欧美亚洲韩国日本久久 | 妇女激情毛片 | 国产又黄又潮娇喘视频免费 | 日韩一级生活片 | a级在线看 | 黄色大片网址 | 国产精品久久99 | 黄色一级大片视频 |