Skip to content

Commit a907026

Browse files
committed
Deprecate X-FRAME-OPTIONS ALLOW-FROM Directive
Closes gh-8677
1 parent 6fbe58e commit a907026

File tree

10 files changed

+55
-34
lines changed

10 files changed

+55
-34
lines changed

config/src/main/resources/org/springframework/security/config/spring-security-5.4.rnc

+4
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,10 @@ frame-options.attlist &=
10341034
attribute value {xsd:string}?
10351035
frame-options.attlist &=
10361036
## Specify the request parameter to use for the origin when using a 'whitelist' or 'regexp' based strategy. Default is 'from'.
1037+
## Deprecated ALLOW-FROM is an obsolete directive that no longer works in modern browsers. Instead use
1038+
## Content-Security-Policy with the
1039+
## <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors">frame-ancestors</a>
1040+
## directive.
10371041
attribute from-parameter {xsd:string}?
10381042

10391043

config/src/main/resources/org/springframework/security/config/spring-security-5.4.xsd

+4-1
Original file line numberDiff line numberDiff line change
@@ -3000,7 +3000,10 @@
30003000
<xs:attribute name="from-parameter" type="xs:string">
30013001
<xs:annotation>
30023002
<xs:documentation>Specify the request parameter to use for the origin when using a 'whitelist' or 'regexp'
3003-
based strategy. Default is 'from'.
3003+
based strategy. Default is 'from'. Deprecated ALLOW-FROM is an obsolete directive that no
3004+
longer works in modern browsers. Instead use Content-Security-Policy with the &lt;a
3005+
href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"&gt;frame-ancestors&lt;/a&gt;
3006+
directive.
30043007
</xs:documentation>
30053008
</xs:annotation>
30063009
</xs:attribute>

config/src/test/java/org/springframework/security/config/doc/XsdDocumentedTests.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ public class XsdDocumentedTests {
5252
"nsa-websocket-security",
5353
"nsa-ldap",
5454
"nsa-method-security",
55-
"nsa-web");
55+
"nsa-web",
56+
// deprecated and for removal
57+
"nsa-frame-options-strategy",
58+
"nsa-frame-options-ref",
59+
"nsa-frame-options-value",
60+
"nsa-frame-options-from-parameter");
5661

5762
String referenceLocation = "../docs/manual/src/docs/asciidoc/_includes/servlet/appendix/namespace.adoc";
5863

docs/manual/src/docs/asciidoc/_includes/servlet/appendix/namespace.adoc

-31
Original file line numberDiff line numberDiff line change
@@ -504,43 +504,12 @@ Default false.
504504
** `DENY` The page cannot be displayed in a frame, regardless of the site attempting to do so.
505505
This is the default when frame-options-policy is specified.
506506
** `SAMEORIGIN` The page can only be displayed in a frame on the same origin as the page itself
507-
** `ALLOW-FROM origin` The page can only be displayed in a frame on the specified origin.
508507

509508
+
510509

511510
In other words, if you specify DENY, not only will attempts to load the page in a frame fail when loaded from other sites, attempts to do so will fail when loaded from the same site.
512511
On the other hand, if you specify SAMEORIGIN, you can still use the page in a frame as long as the site including it in a frame it is the same as the one serving the page.
513512

514-
[[nsa-frame-options-strategy]]
515-
* **strategy**
516-
Select the `AllowFromStrategy` to use when using the ALLOW-FROM policy.
517-
518-
** `static` Use a single static ALLOW-FROM value.
519-
The value can be set through the <<nsa-frame-options-value,value>> attribute.
520-
** `regexp` Use a regular expression to validate incoming requests and if they are allowed.
521-
The regular expression can be set through the <<nsa-frame-options-value,value>> attribute.
522-
The request parameter used to retrieve the value to validate can be specified using the <<nsa-frame-options-from-parameter,from-parameter>>.
523-
** `whitelist` A comma-separated list containing the allowed domains.
524-
The comma-separated list can be set through the <<nsa-frame-options-value,value>> attribute.
525-
The request parameter used to retrieve the value to validate can be specified using the <<nsa-frame-options-from-parameter,from-parameter>>.
526-
527-
528-
529-
530-
[[nsa-frame-options-ref]]
531-
* **ref**
532-
Instead of using one of the predefined strategies it is also possible to use a custom `AllowFromStrategy`.
533-
The reference to this bean can be specified through this ref attribute.
534-
535-
536-
[[nsa-frame-options-value]]
537-
* **value**
538-
The value to use when ALLOW-FROM is used a <<nsa-frame-options-strategy,strategy>>.
539-
540-
541-
[[nsa-frame-options-from-parameter]]
542-
* **from-parameter**
543-
Specify the name of the request parameter to use when using regexp or whitelist for the ALLOW-FROM strategy.
544513

545514

546515
[[nsa-frame-options-parents]]

web/src/main/java/org/springframework/security/web/header/writers/frameoptions/AbstractRequestParameterAllowFromStrategy.java

+5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
*
3030
* @author Marten Deinum
3131
* @since 3.2
32+
* @deprecated ALLOW-FROM is an obsolete directive that no longer works in modern browsers. Instead use
33+
* Content-Security-Policy with the
34+
* <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors">frame-ancestors</a>
35+
* directive.
3236
*/
37+
@Deprecated
3338
abstract class AbstractRequestParameterAllowFromStrategy implements AllowFromStrategy {
3439

3540
private static final String DEFAULT_ORIGIN_REQUEST_PARAMETER = "x-frames-allow-from";

web/src/main/java/org/springframework/security/web/header/writers/frameoptions/AllowFromStrategy.java

+5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
*
2424
* @author Marten Deinum
2525
* @since 3.2
26+
* @deprecated ALLOW-FROM is an obsolete directive that no longer works in modern browsers. Instead use
27+
* Content-Security-Policy with the
28+
* <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors">frame-ancestors</a>
29+
* directive.
2630
*/
31+
@Deprecated
2732
public interface AllowFromStrategy {
2833

2934
/**

web/src/main/java/org/springframework/security/web/header/writers/frameoptions/RegExpAllowFromStrategy.java

+5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
*
2727
* @author Marten Deinum
2828
* @since 3.2
29+
* @deprecated ALLOW-FROM is an obsolete directive that no longer works in modern browsers. Instead use
30+
* Content-Security-Policy with the
31+
* <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors">frame-ancestors</a>
32+
* directive.
2933
*/
34+
@Deprecated
3035
public final class RegExpAllowFromStrategy extends
3136
AbstractRequestParameterAllowFromStrategy {
3237

web/src/main/java/org/springframework/security/web/header/writers/frameoptions/StaticAllowFromStrategy.java

+6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020

2121
/**
2222
* Simple implementation of the {@code AllowFromStrategy}
23+
*
24+
* @deprecated ALLOW-FROM is an obsolete directive that no longer works in modern browsers. Instead use
25+
* Content-Security-Policy with the
26+
* <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors">frame-ancestors</a>
27+
* directive.
2328
*/
29+
@Deprecated
2430
public final class StaticAllowFromStrategy implements AllowFromStrategy {
2531

2632
private final URI uri;

web/src/main/java/org/springframework/security/web/header/writers/frameoptions/WhiteListedAllowFromStrategy.java

+5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
*
2525
* @author Marten Deinum
2626
* @since 3.2
27+
* @deprecated ALLOW-FROM is an obsolete directive that no longer works in modern browsers. Instead use
28+
* Content-Security-Policy with the
29+
* <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors">frame-ancestors</a>
30+
* directive.
2731
*/
32+
@Deprecated
2833
public final class WhiteListedAllowFromStrategy extends
2934
AbstractRequestParameterAllowFromStrategy {
3035

web/src/main/java/org/springframework/security/web/header/writers/frameoptions/XFrameOptionsHeaderWriter.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ public XFrameOptionsHeaderWriter(XFrameOptionsMode frameOptionsMode) {
6868
*
6969
* @param allowFromStrategy the strategy for determining what the value for ALLOW_FROM
7070
* is.
71+
*
72+
* @deprecated ALLOW-FROM is an obsolete directive that no longer works in modern browsers. Instead use
73+
* Content-Security-Policy with the
74+
* <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors">frame-ancestors</a>
75+
* directive.
7176
*/
77+
@Deprecated
7278
public XFrameOptionsHeaderWriter(AllowFromStrategy allowFromStrategy) {
7379
Assert.notNull(allowFromStrategy, "allowFromStrategy cannot be null");
7480
this.frameOptionsMode = XFrameOptionsMode.ALLOW_FROM;
@@ -107,7 +113,15 @@ public void writeHeaders(HttpServletRequest request, HttpServletResponse respons
107113
* @since 3.2
108114
*/
109115
public enum XFrameOptionsMode {
110-
DENY("DENY"), SAMEORIGIN("SAMEORIGIN"), ALLOW_FROM("ALLOW-FROM");
116+
DENY("DENY"), SAMEORIGIN("SAMEORIGIN"),
117+
/**
118+
* @deprecated ALLOW-FROM is an obsolete directive that no longer works in modern browsers. Instead use
119+
* Content-Security-Policy with the
120+
* <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors">frame-ancestors</a>
121+
* directive.
122+
*/
123+
@Deprecated
124+
ALLOW_FROM("ALLOW-FROM");
111125

112126
private String mode;
113127

0 commit comments

Comments
 (0)