|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.security.config.annotation.web.configurers;
|
18 | 18 |
|
19 |
| -import java.net.URI; |
20 | 19 | import java.util.Collections;
|
21 | 20 | import java.util.LinkedHashMap;
|
22 | 21 | import java.util.Map;
|
|
35 | 34 | import org.springframework.security.web.SecurityFilterChain;
|
36 | 35 | import org.springframework.security.web.header.writers.StaticHeadersWriter;
|
37 | 36 | import org.springframework.security.web.header.writers.XXssProtectionHeaderWriter;
|
38 |
| -import org.springframework.security.web.header.writers.frameoptions.StaticAllowFromStrategy; |
39 |
| -import org.springframework.security.web.header.writers.frameoptions.XFrameOptionsHeaderWriter; |
40 | 37 | import org.springframework.security.web.util.matcher.AnyRequestMatcher;
|
41 | 38 | import org.springframework.test.web.servlet.MockMvc;
|
42 | 39 | import org.springframework.test.web.servlet.ResultMatcher;
|
@@ -102,13 +99,6 @@ public void requestWhenFrameOptionsSameOriginThenBehaviorMatchesNamespace() thro
|
102 | 99 | this.mvc.perform(get("/")).andExpect(includes(Collections.singletonMap("X-Frame-Options", "SAMEORIGIN")));
|
103 | 100 | }
|
104 | 101 |
|
105 |
| - @Test |
106 |
| - public void requestWhenFrameOptionsAllowFromThenBehaviorMatchesNamespace() throws Exception { |
107 |
| - this.spring.register(FrameOptionsAllowFromConfig.class).autowire(); |
108 |
| - this.mvc.perform(get("/")) |
109 |
| - .andExpect(includes(Collections.singletonMap("X-Frame-Options", "ALLOW-FROM https://example.com"))); |
110 |
| - } |
111 |
| - |
112 | 102 | @Test
|
113 | 103 | public void requestWhenXssOnlyThenBehaviorMatchesNamespace() throws Exception {
|
114 | 104 | this.spring.register(XssProtectionConfig.class).autowire();
|
@@ -243,25 +233,6 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
243 | 233 |
|
244 | 234 | }
|
245 | 235 |
|
246 |
| - @Configuration |
247 |
| - @EnableWebSecurity |
248 |
| - static class FrameOptionsAllowFromConfig { |
249 |
| - |
250 |
| - @Bean |
251 |
| - SecurityFilterChain filterChain(HttpSecurity http) throws Exception { |
252 |
| - // @formatter:off |
253 |
| - http |
254 |
| - .headers((headers) -> headers |
255 |
| - // frame-options@ref |
256 |
| - .defaultsDisabled() |
257 |
| - .addHeaderWriter(new XFrameOptionsHeaderWriter( |
258 |
| - new StaticAllowFromStrategy(URI.create("https://example.com"))))); |
259 |
| - return http.build(); |
260 |
| - // @formatter:on |
261 |
| - } |
262 |
| - |
263 |
| - } |
264 |
| - |
265 | 236 | @Configuration
|
266 | 237 | @EnableWebSecurity
|
267 | 238 | static class XssProtectionConfig {
|
|
0 commit comments