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:11:51 UTC
[GitHub] [shiro] bdemers edited a comment on issue #85: [SHIRO-687] Adding Spring's Filters to ShiroFilterFactorBean when using Java config
bdemers edited a comment 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;
}
```
We probably need to stick that in the release notes. (And there are other ways around this too, for example, if the Filter was a `OncePerRequestFilter` it _should_ be skipped in later visits anyway.)
----------------------------------------------------------------
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