Skip to content

Commit 9fa9985

Browse files
committed
Fix test and add security configuration
1 parent c7bcc73 commit 9fa9985

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2013-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.gateway.server.mvc;
18+
19+
import org.springframework.context.annotation.Bean;
20+
import org.springframework.context.annotation.Configuration;
21+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
22+
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
23+
import org.springframework.security.web.SecurityFilterChain;
24+
25+
/**
26+
* @author Ryan Baxter
27+
*/
28+
@Configuration(proxyBeanMethods = false)
29+
public class PermitAllSecurityConfiguration {
30+
31+
@Bean
32+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
33+
http.authorizeHttpRequests(auth -> auth.anyRequest().permitAll()).csrf(AbstractHttpConfigurer::disable);
34+
return http.build();
35+
}
36+
37+
}

spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/filter/ForwardedRequestHeadersFilterTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Map;
2626
import java.util.Optional;
2727

28-
import org.junit.jupiter.api.Disabled;
2928
import org.junit.jupiter.api.Test;
3029

3130
import org.springframework.cloud.gateway.server.mvc.filter.ForwardedRequestHeadersFilter.Forwarded;
@@ -141,10 +140,9 @@ public void noHostHeader() throws UnknownHostException {
141140
}
142141

143142
@Test
144-
@Disabled
145143
public void correctIPv6RemoteAddressMapping() throws UnknownHostException {
146144
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get")
147-
.remoteAddress("2001:db8:cafe:0:0:0:0:17:80")
145+
.remoteAddress("2001:db8:cafe:0:0:0:0:17")
148146
.header(HttpHeaders.HOST, "myhost")
149147
.buildRequest(null);
150148
servletRequest.setRemoteHost("2001:db8:cafe:0:0:0:0:17");

0 commit comments

Comments
 (0)