Skip to content

Commit 0e4e25d

Browse files
committed
Updates to CORS patterns contribution
Closes gh-25016
1 parent 1181bb1 commit 0e4e25d

File tree

24 files changed

+486
-254
lines changed

24 files changed

+486
-254
lines changed

spring-web/src/main/java/org/springframework/web/bind/annotation/CrossOrigin.java

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.lang.annotation.Retention;
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
24+
import java.util.List;
2425

2526
import org.springframework.core.annotation.AliasFor;
2627
import org.springframework.web.cors.CorsConfiguration;
@@ -77,37 +78,20 @@
7778
String[] value() default {};
7879

7980
/**
80-
* The list of allowed origins that be specific origins, e.g.
81-
* {@code "https://domain1.com"}, or {@code "*"} for all origins.
82-
* <p>A matched origin is listed in the {@code Access-Control-Allow-Origin}
83-
* response header of preflight actual CORS requests.
84-
* <p>By default all origins are allowed.
85-
* <p><strong>Note:</strong> CORS checks use values from "Forwarded"
86-
* (<a href="https://tools.ietf.org/html/rfc7239">RFC 7239</a>),
87-
* "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" headers,
88-
* if present, in order to reflect the client-originated address.
89-
* Consider using the {@code ForwardedHeaderFilter} in order to choose from a
90-
* central place whether to extract and use, or to discard such headers.
91-
* See the Spring Framework reference for more on this filter.
92-
* @see #value
81+
* A list of origins for which cross-origin requests are allowed. Please,
82+
* see {@link CorsConfiguration#setAllowedOrigins(List)} for details.
83+
* <p>By default all origins are allowed unless {@code originPatterns} is
84+
* also set in which case {@code originPatterns} is used instead.
9385
*/
9486
@AliasFor("value")
9587
String[] origins() default {};
9688

9789
/**
98-
* The list of allowed origins patterns that be specific origins, e.g.
99-
* {@code ".*\.domain1\.com"}, or {@code ".*"} for matching all origins.
100-
* <p>A matched origin is listed in the {@code Access-Control-Allow-Origin}
101-
* response header of preflight actual CORS requests.
102-
* <p>By default all origins are allowed.
103-
* <p><strong>Note:</strong> CORS checks use values from "Forwarded"
104-
* (<a href="https://tools.ietf.org/html/rfc7239">RFC 7239</a>),
105-
* "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" headers,
106-
* if present, in order to reflect the client-originated address.
107-
* Consider using the {@code ForwardedHeaderFilter} in order to choose from a
108-
* central place whether to extract and use, or to discard such headers.
109-
* See the Spring Framework reference for more on this filter.
110-
* @see #value
90+
* Alternative to {@link #origins()} that supports origins declared via
91+
* wildcard patterns. Please, see
92+
* @link CorsConfiguration#setAllowedOriginPatterns(List)} for details.
93+
* <p>By default this is not set.
94+
* @since 5.3
11195
*/
11296
String[] originPatterns() default {};
11397

0 commit comments

Comments
 (0)