Move a wildcard CORS origin to allowedOriginPatterns where credentials are allowed
ProprietarySpring Framework 5.3 rejects a CORS configuration that allows credentials and also lists "*" among its allowed origins: CorsConfiguration.validateAllowCredentials() throws IllegalArgumentException. Spring itself calls it, so such an application fails rather than misbehaving quietly: AbstractHandlerMapping calls it as the configuration is registered in both Spring MVC and WebFlux, which fails at startup, and CorsConfiguration.checkOrigin calls it whenever the allowed origins hold "*", which is the CorsFilter path and fails on the first cross-origin request instead. Moves the wildcard to the patterns property that 5.3 added for exactly this case, setAllowedOriginPatterns, addAllowedOriginPattern, allowedOriginPatterns and the @CrossOrigin originPatterns attribute. Only a configuration that both allows credentials and carries a literal "*" origin is changed, since that is the only combination 5.3 rejects; a wildcard origin without credentials is still valid and is left alone, as is a configuration that allows credentials without naming any origin, which the validation explicitly permits. An origin given by a variable or a constant is left alone too, because nothing proves it is the wildcard.
io. moderne. java. spring. framework. MigrateCorsAllowCredentialsWildcardmod run . --recipe= io. moderne. java. spring. framework. MigrateCorsAllowCredentialsWildcardInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.