其他分享
首页 > 其他分享> > swagger+shiro20220727

swagger+shiro20220727

作者:互联网

/** 创建一个配置类,创建一个叫做shiroFilter的bean,这就是shiro的过滤器配置类,设置对应的过滤条件和跳转条件,下面我只写了swagger中不需要shiro过滤的文件 **/
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean shiroFilterFactoryBean(@Qualifier("securityManager") SecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
// 配置不会被拦截的链接 顺序判断
filterChainDefinitionMap.put("/static/**", "anon");
filterChainDefinitionMap.put("/login", "anon");

 


//被shiro拦截的swagger资源放行
filterChainDefinitionMap.put("/doc.html/**", "anon");
filterChainDefinitionMap.put("/swagger-resources/**", "anon");
filterChainDefinitionMap.put("/v2/api-docs/**", "anon");
filterChainDefinitionMap.put("/webjars/**", "anon");
filterChainDefinitionMap.put("/swagger-resources/configuration/ui/**", "anon");
filterChainDefinitionMap.put("/swagger-resources/configuration/security/**", "anon");


shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}

标签:anon,put,shiro20220727,swagger,filterChainDefinitionMap,shiroFilterFactoryBean,s
来源: https://www.cnblogs.com/smallfa/p/16524892.html