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 @@
<properties>
<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>
<dependencies>
......
......@@ -27,10 +27,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
......@@ -41,12 +40,6 @@ public class ResponseHeaderFIlter implements Filter {
@Autowired
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
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
......@@ -56,8 +49,8 @@ public class ResponseHeaderFIlter implements Filter {
HttpServletResponse httpResponse = (HttpServletResponse) response;
this.dpsHeaders.addCorrelationIdIfMissing();
Map<String, String> responseHeaders = responseHeadersFactory.getResponseHeaders(ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS);
for(Map.Entry<String, String> header : responseHeaders.entrySet()){
Map<String, List<Object>> standardHeaders = ResponseHeaders.STANDARD_RESPONSE_HEADERS;
for (Map.Entry<String, List<Object>> header : standardHeaders.entrySet()) {
httpResponse.addHeader(header.getKey(), header.getValue().toString());
}
httpResponse.addHeader(DpsHeaders.CORRELATION_ID, this.dpsHeaders.getCorrelationId());
......@@ -72,4 +65,4 @@ public class ResponseHeaderFIlter implements Filter {
@Override
public void destroy() {
}
}
\ No newline at end of file
}
......@@ -39,7 +39,6 @@ public class ResponseHeaderFilterTest {
public void test_ResponseHeaderFiler_Options() throws IOException, ServletException {
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);
assertNotNull(httpServletResponse);
responseHeaderFIlter.destroy();
......@@ -50,7 +49,6 @@ public class ResponseHeaderFilterTest {
public void test_ResponseHeaderFiler_Get() throws IOException, ServletException {
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);
assertNotNull(httpServletResponse);
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