title: How to configure Shiro with Spring Boot
body: <p>I have a Spring MVC web application that uses Shiro authentication using Spring configuration rather than a shiro.ini.</p>
  
  <p>I want to transition to a Spring Boot application.</p>
  
  <p>I have been mainly successful. The application starts in Spring Boot and my Shiro environment gets setup. However I just cannot work out how to setup the Shiro Filter correctly. I need this to be working to make sure requests end up being handled by the correct thread.</p>
  
  <p>In the original app I configured the Shiro Filter in the web.xml like this:</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;shiroFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;targetFilterLifecycle&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;shiroFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>I have tried replicate this using a Java Config like this:</p>
  
  <pre><code>  @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;
    }
  </code></pre>
  
  <p>However I just cannot get everything to fit together and don't have enough knowledge to sort it out. I just can't see to connect the filter to the environment. I would guess it is something to do with the order things are setup.</p>
  
  <p>Has anyone managed to use Spring Boot and Shiro together successfully?</p>