|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -310,17 +310,24 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Configure allowed {@code Origin} header values. This check is mostly |
|
|
|
* Set the origins for which cross-origin requests are allowed from a browser. |
|
|
|
* designed for browsers. There is nothing preventing other types of client |
|
|
|
* Please, refer to {@link CorsConfiguration#setAllowedOrigins(List)} for |
|
|
|
* to modify the {@code Origin} header value. |
|
|
|
* format details and considerations, and keep in mind that the CORS spec |
|
|
|
* <p>When SockJS is enabled and origins are restricted, transport types |
|
|
|
* does not allow use of {@code "*"} with {@code allowCredentials=true}. |
|
|
|
* that do not allow to check request origin (Iframe based transports) |
|
|
|
* For more flexible origin patterns use {@link #setAllowedOriginPatterns} |
|
|
|
* are disabled. As a consequence, IE 6 to 9 are not supported when origins |
|
|
|
* instead. |
|
|
|
* are restricted. |
|
|
|
* |
|
|
|
* <p>Each provided allowed origin must have a scheme, and optionally a port |
|
|
|
* <p>By default, no origins are allowed. When |
|
|
|
* (e.g. "https://example.org", "https://example.org:9090"). An allowed origin |
|
|
|
* {@link #setAllowedOriginPatterns(Collection) allowedOriginPatterns} is also |
|
|
|
* string may also be "*" in which case all origins are allowed. |
|
|
|
* set, then that takes precedence over this property. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>Note when SockJS is enabled and origins are restricted, transport types |
|
|
|
|
|
|
|
* that do not allow to check request origin (Iframe based transports) are |
|
|
|
|
|
|
|
* disabled. As a consequence, IE 6 to 9 are not supported when origins are |
|
|
|
|
|
|
|
* restricted. |
|
|
|
|
|
|
|
* |
|
|
|
* @since 4.1.2 |
|
|
|
* @since 4.1.2 |
|
|
|
|
|
|
|
* @see #setAllowedOriginPatterns(Collection) |
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6454">RFC 6454: The Web Origin Concept</a> |
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6454">RFC 6454: The Web Origin Concept</a> |
|
|
|
* @see <a href="https://github.com/sockjs/sockjs-client#supported-transports-by-browser-html-served-from-http-or-https">SockJS supported transports by browser</a> |
|
|
|
* @see <a href="https://github.com/sockjs/sockjs-client#supported-transports-by-browser-html-served-from-http-or-https">SockJS supported transports by browser</a> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -330,19 +337,19 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return configure allowed {@code Origin} header values. |
|
|
|
* Return the {@link #setAllowedOrigins(Collection) configured} allowed origins. |
|
|
|
* @since 4.1.2 |
|
|
|
* @since 4.1.2 |
|
|
|
* @see #setAllowedOrigins |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings("ConstantConditions") |
|
|
|
@SuppressWarnings("ConstantConditions") |
|
|
|
public Collection<String> getAllowedOrigins() { |
|
|
|
public Collection<String> getAllowedOrigins() { |
|
|
|
return this.corsConfiguration.getAllowedOrigins(); |
|
|
|
return this.corsConfiguration.getAllowedOrigins(); |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
|
* A variant of {@link #setAllowedOrigins(Collection)} that accepts flexible |
|
|
|
* Alternative to {@link #setAllowedOrigins(Collection)} that supports more |
|
|
|
* domain patterns, e.g. {@code "https://*.domain1.com"}. Furthermore it |
|
|
|
* flexible patterns for specifying the origins for which cross-origin |
|
|
|
* always sets the {@code Access-Control-Allow-Origin} response header to |
|
|
|
* requests are allowed from a browser. Please, refer to |
|
|
|
* the matched origin and never to {@code "*"}, nor to any other pattern. |
|
|
|
* {@link CorsConfiguration#setAllowedOriginPatterns(List)} for format |
|
|
|
|
|
|
|
* details and other considerations. |
|
|
|
* <p>By default this is not set. |
|
|
|
* <p>By default this is not set. |
|
|
|
* @since 5.2.3 |
|
|
|
* @since 5.2.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -354,7 +361,6 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return {@link #setAllowedOriginPatterns(Collection) configured} origin patterns. |
|
|
|
* Return {@link #setAllowedOriginPatterns(Collection) configured} origin patterns. |
|
|
|
* @since 5.3.2 |
|
|
|
* @since 5.3.2 |
|
|
|
* @see #setAllowedOriginPatterns |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings("ConstantConditions") |
|
|
|
@SuppressWarnings("ConstantConditions") |
|
|
|
public Collection<String> getAllowedOriginPatterns() { |
|
|
|
public Collection<String> getAllowedOriginPatterns() { |
|
|
|
|