File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
config/src/main/java/org/springframework/security/config/annotation/web/configurers Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 2424import org .springframework .util .ClassUtils ;
2525import org .springframework .web .cors .CorsConfiguration ;
2626import org .springframework .web .cors .CorsConfigurationSource ;
27+ import org .springframework .web .cors .PreFlightRequestHandler ;
2728import org .springframework .web .filter .CorsFilter ;
2829import org .springframework .web .servlet .handler .HandlerMappingIntrospector ;
2930
@@ -110,11 +111,13 @@ private static CorsFilter getMvcCorsFilter(ApplicationContext context) {
110111 if (!context .containsBean (HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME )) {
111112 throw new NoSuchBeanDefinitionException (HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME , "A Bean named "
112113 + HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME + " of type "
113- + HandlerMappingIntrospector .class .getName ()
114+ + PreFlightRequestHandler .class .getName ()
114115 + " is required to use MvcRequestMatcher. Please ensure Spring Security & Spring MVC are configured in a shared ApplicationContext." );
115116 }
116- HandlerMappingIntrospector mappingIntrospector = context .getBean (HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME ,
117- HandlerMappingIntrospector .class );
117+ PreFlightRequestHandler mappingIntrospector = context .getBean (HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME ,
118+ PreFlightRequestHandler .class );
119+ Assert .isInstanceOf (CorsConfigurationSource .class , mappingIntrospector ,
120+ () -> "mappingIntrospector must implement " + CorsConfigurationSource .class .getName ());
118121 return new CorsFilter (mappingIntrospector );
119122 }
120123
You can’t perform that action at this time.
0 commit comments