You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by GitBox <gi...@apache.org> on 2019/12/05 17:09:31 UTC

[GitHub] [shiro] bdemers commented on issue #85: [SHIRO-687] Adding Spring's Filters to ShiroFilterFactorBean when using Java config

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:
users@infra.apache.org


With regards,
Apache Git Services