I have a Spring MVC web application that uses Shiro authentication using Spring configuration, not shiro.ini.
I want to switch to the Spring boot application.
I was mostly successful. The application runs in Spring Boot and my Shiro environment gets set up. However, I just can't figure out how to properly configure the Shiro filter. I need this to work to make sure that the requests are ultimately handled by the correct thread.
In the original application, I configured the Shiro filter in the web.xml file as follows:
<filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
I tried to replicate this using Java Config as follows:
@Autowired private WebSecurityManager webSecurityManager; @Bean public ShiroFilterFactoryBean shiroFilterFactoryBean() { ShiroFilterFactoryBean shiroFilterFactoryBean = new org.apache.shiro.spring.web.ShiroFilterFactoryBean(); shiroFilterFactoryBean.setSecurityManager(webSecurityManager); return shiroFilterFactoryBean; } @Bean public org.apache.shiro.spring.LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { return new org.apache.shiro.spring.LifecycleBeanPostProcessor(); } @Bean public Filter shiroFilter() { DelegatingFilterProxy filter = new DelegatingFilterProxy(); filter.setTargetBeanName("shiroFilterFactoryBean"); filter.setTargetFilterLifecycle(true); return filter; }
However, I just canโt get everything to match each other, and I donโt have enough knowledge to figure it out. I just do not see to connect the filter to the environment. I would suggest that this has something to do with setting up an order.
Has anyone been able to successfully use Spring Boot and Shiro together?
source share