use of org.apereo.cas.configuration.model.core.web.security.HttpCorsRequestProperties in project cas by apereo.
the class CasFiltersConfiguration method casCorsFilter.
@ConditionalOnProperty(prefix = "cas.httpWebRequest.cors", name = "enabled", havingValue = "true")
@Bean
@RefreshScope
public FilterRegistrationBean casCorsFilter() {
final HttpCorsRequestProperties cors = casProperties.getHttpWebRequest().getCors();
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
final CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(cors.isEnabled());
config.setAllowedOrigins(cors.getAllowOrigins());
config.setAllowedMethods(cors.getAllowMethods());
config.setAllowedHeaders(cors.getAllowHeaders());
config.setMaxAge(cors.getMaxAge());
config.setExposedHeaders(cors.getExposedHeaders());
source.registerCorsConfiguration("/**", config);
final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setName("casCorsFilter");
bean.setAsyncSupported(true);
bean.setOrder(0);
return bean;
}
Aggregations