use of org.springframework.web.filter.OncePerRequestFilter in project flow by vaadin.
the class Application method publicImagesAliasFilter.
// Test views use relative path to images, that cannot be correctly resolved
// where setting vaadin.urlMapping, because view base path differs from
// web application context path
// The following filter forwards request from
// {vaadin.urlMapping}/public/images
// to /public/images, so they are then served by spring.
@Bean
FilterRegistrationBean<?> publicImagesAliasFilter() {
FilterRegistrationBean<OncePerRequestFilter> registrationBean = new FilterRegistrationBean<>(new OncePerRequestFilter() {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
request.getRequestDispatcher(request.getRequestURI().substring(7)).forward(request, response);
}
});
registrationBean.addUrlPatterns("/vaadin/public/images/*", "/vaadin/public/profiles/*");
registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
return registrationBean;
}
use of org.springframework.web.filter.OncePerRequestFilter in project openlmis-stockmanagement by OpenLMIS.
the class ResourceServerSecurityConfiguration method configure.
@Override
public void configure(HttpSecurity http) throws Exception {
http.addFilterAfter(new OncePerRequestFilter() {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
// the security context in case it is actually an OAuth2Authentication
if (tokenExtractor.extract(request) == null) {
SecurityContextHolder.clearContext();
}
filterChain.doFilter(request, response);
}
}, AbstractPreAuthenticatedProcessingFilter.class);
http.csrf().disable();
http.authorizeRequests().antMatchers("/stockmanagement", "/webjars/**", "/stockmanagement/webjars/**", "/stockmanagement/docs/**").permitAll().antMatchers("/**").fullyAuthenticated();
}
Aggregations