Skip to content
Snippets Groups Projects
Commit b02d1597 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

disable caching for api responses

parent bde9f1ab
No related branches found
No related tags found
4 merge requests!678Merge 12.2.0 beta.2 into master,!67712.2.0~beta.2 into master,!676Devel 12.2.0~beta.2 into master,!654Resolve "Empty field "Email used for requesting an account" crashes tabs in Configuration"
Pipeline #8905 failed
package lcsb.mapviewer.web.bean.utils;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
/**
* This filter enables x-frames from another domain if necessary.
*
* @author Piotr Gawron
*
*/
public class ApiAccessControlFilter implements Filter {
/**
* Default class logger.
*/
@SuppressWarnings("unused")
private final Logger logger = Logger.getLogger(ApiAccessControlFilter.class);
@Override
public void init(FilterConfig config) throws ServletException {
}
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
response.addHeader("Vary", "*");
chain.doFilter(req, response);
}
@Override
public void destroy() {
}
}
package lcsb.mapviewer.web.config;
import java.io.InputStream;
import java.util.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Properties;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
......@@ -23,6 +25,7 @@ import lcsb.mapviewer.annotation.SpringAnnotationConfig;
import lcsb.mapviewer.api.SpringRestApiConfig;
import lcsb.mapviewer.persist.SpringPersistConfig;
import lcsb.mapviewer.services.SpringServiceConfig;
import lcsb.mapviewer.web.bean.utils.ApiAccessControlFilter;
import lcsb.mapviewer.web.bean.utils.JsfAjaxAccessControlAllowFilter;
import lcsb.mapviewer.web.bean.utils.XFrameAccessControlFilter;
......@@ -94,6 +97,11 @@ public class WebAppInitializer implements WebApplicationInitializer {
jsfAjaxAccessControlAllowFilter);
jsfAjaxAccessControlAllowFilterReg.addMappingForUrlPatterns(null, true, "/*");
ApiAccessControlFilter apiFilter = new ApiAccessControlFilter();
FilterRegistration.Dynamic apiFilterReg = container.addFilter("apiFilter", apiFilter);
apiFilterReg.addMappingForUrlPatterns(null, true, "/api/*");
/*
* =============== COOKIE SETTINGS ===============
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment