Commit 60142367 authored by Sutton's avatar Sutton
Browse files

Reverting cors changes

parent e02a8e24
Pipeline #28753 canceled with stages
in 6 minutes and 10 seconds
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<properties> <properties>
<springfox-version>2.7.0</springfox-version> <springfox-version>2.7.0</springfox-version>
<os-core-common.version>0.3.28</os-core-common.version> <os-core-common.version>0.3.23</os-core-common.version>
</properties> </properties>
<dependencies> <dependencies>
......
...@@ -27,10 +27,9 @@ import javax.servlet.http.HttpServletRequest; ...@@ -27,10 +27,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.http.ResponseHeadersFactory; import org.opengroup.osdu.core.common.http.ResponseHeaders;
import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
...@@ -41,12 +40,6 @@ public class ResponseHeaderFIlter implements Filter { ...@@ -41,12 +40,6 @@ public class ResponseHeaderFIlter implements Filter {
@Autowired @Autowired
private DpsHeaders dpsHeaders; private DpsHeaders dpsHeaders;
// defaults to * for any front-end, string must be comma-delimited if more than one domain
@Value("${ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS:*}")
String ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS;
private ResponseHeadersFactory responseHeadersFactory = new ResponseHeadersFactory();
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException { throws IOException, ServletException {
...@@ -56,8 +49,8 @@ public class ResponseHeaderFIlter implements Filter { ...@@ -56,8 +49,8 @@ public class ResponseHeaderFIlter implements Filter {
HttpServletResponse httpResponse = (HttpServletResponse) response; HttpServletResponse httpResponse = (HttpServletResponse) response;
this.dpsHeaders.addCorrelationIdIfMissing(); this.dpsHeaders.addCorrelationIdIfMissing();
Map<String, String> responseHeaders = responseHeadersFactory.getResponseHeaders(ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS); Map<String, List<Object>> standardHeaders = ResponseHeaders.STANDARD_RESPONSE_HEADERS;
for(Map.Entry<String, String> header : responseHeaders.entrySet()){ for (Map.Entry<String, List<Object>> header : standardHeaders.entrySet()) {
httpResponse.addHeader(header.getKey(), header.getValue().toString()); httpResponse.addHeader(header.getKey(), header.getValue().toString());
} }
httpResponse.addHeader(DpsHeaders.CORRELATION_ID, this.dpsHeaders.getCorrelationId()); httpResponse.addHeader(DpsHeaders.CORRELATION_ID, this.dpsHeaders.getCorrelationId());
...@@ -72,4 +65,4 @@ public class ResponseHeaderFIlter implements Filter { ...@@ -72,4 +65,4 @@ public class ResponseHeaderFIlter implements Filter {
@Override @Override
public void destroy() { public void destroy() {
} }
} }
\ No newline at end of file
...@@ -39,7 +39,6 @@ public class ResponseHeaderFilterTest { ...@@ -39,7 +39,6 @@ public class ResponseHeaderFilterTest {
public void test_ResponseHeaderFiler_Options() throws IOException, ServletException { public void test_ResponseHeaderFiler_Options() throws IOException, ServletException {
Mockito.when(httpServletRequest.getMethod()).thenReturn("OPTIONS"); Mockito.when(httpServletRequest.getMethod()).thenReturn("OPTIONS");
org.springframework.test.util.ReflectionTestUtils.setField(responseHeaderFIlter, "ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS", "custom-domain");
responseHeaderFIlter.doFilter(httpServletRequest, httpServletResponse, chain); responseHeaderFIlter.doFilter(httpServletRequest, httpServletResponse, chain);
assertNotNull(httpServletResponse); assertNotNull(httpServletResponse);
responseHeaderFIlter.destroy(); responseHeaderFIlter.destroy();
...@@ -50,7 +49,6 @@ public class ResponseHeaderFilterTest { ...@@ -50,7 +49,6 @@ public class ResponseHeaderFilterTest {
public void test_ResponseHeaderFiler_Get() throws IOException, ServletException { public void test_ResponseHeaderFiler_Get() throws IOException, ServletException {
Mockito.when(httpServletRequest.getMethod()).thenReturn("GET"); Mockito.when(httpServletRequest.getMethod()).thenReturn("GET");
org.springframework.test.util.ReflectionTestUtils.setField(responseHeaderFIlter, "ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS", "custom-domain");
responseHeaderFIlter.doFilter(httpServletRequest, httpServletResponse, chain); responseHeaderFIlter.doFilter(httpServletRequest, httpServletResponse, chain);
assertNotNull(httpServletResponse); assertNotNull(httpServletResponse);
responseHeaderFIlter.destroy(); responseHeaderFIlter.destroy();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment