bdemers commented on issue #85: [SHIRO-687] Adding Spring's Filters to 
ShiroFilterFactorBean when using Java config
URL: https://github.com/apache/shiro/pull/85#issuecomment-562222877
 
 
   @fpapon I just dusted this off, and did a little manual testing.
   
   One thing of note is that when using this with Spring Boot you also need a 
`FilterRegistrationBean` to disable the filter (so Shrio manages it instead of 
Spring)
   
   
   ```java
       @Bean
       public ShiroFilterChainDefinition shiroFilterChainDefinition() {
           DefaultShiroFilterChainDefinition chainDefinition = new 
DefaultShiroFilterChainDefinition();
           chainDefinition.addPathDefinition("/login.html", "authc"); // need 
to accept POSTs from the login form
           chainDefinition.addPathDefinition("/account-info", "testFilter"); // 
match the bean name below
           chainDefinition.addPathDefinition("/logout", "logout");
           return chainDefinition;
       }
   
       @Bean
       public ExpectedTestFilter testFilter() {
           return new ExpectedTestFilter();
       }
   
       @Bean
       public FilterRegistrationBean<ExpectedTestFilter> 
testFilterRegBean(ExpectedTestFilter testFilter) {
           FilterRegistrationBean<ExpectedTestFilter> registrationBean = new 
FilterRegistrationBean<>();
           registrationBean.setFilter(testFilter);
           registrationBean.setEnabled(false);
           return registrationBean;
       }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to