chore: import verified syly2 maintenance baseline without embedded credentials
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package uat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
|
||||
/** Deployment-only boundary for the isolated restored UAT copy. */
|
||||
public class UatGuardFilter implements Filter {
|
||||
public void init(FilterConfig config) {}
|
||||
public void destroy() {}
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse res = (HttpServletResponse) response;
|
||||
String path = req.getServletPath().toLowerCase(Locale.ROOT);
|
||||
res.setHeader("X-Syly-Environment", "isolated-uat");
|
||||
res.setHeader("X-Content-Type-Options", "nosniff");
|
||||
if (path.contains("appservice") || path.contains("repaircontroller") || path.contains("dataupdatecontroller")
|
||||
|| path.contains("druid") || path.equals("/rest") || path.startsWith("/rest/") || path.contains("connector.java")
|
||||
|| path.contains("filesuploadcontroller") || path.contains("/ueditor/jsp/")
|
||||
|| (path.contains("usercontroller") && req.getParameterMap().containsKey("savenewpwdforuser"))) {
|
||||
res.sendError(403, "Disabled in isolated UAT"); return;
|
||||
}
|
||||
boolean login = path.equals("/logincontroller.do") || path.equals("/logincontroller.action");
|
||||
if (login && req.getParameterMap().containsKey("checkuser")
|
||||
&& !"uat_admin".equals(req.getParameter("userName"))) {
|
||||
res.setContentType("application/json;charset=UTF-8");
|
||||
res.getWriter().write("{\"success\":false,\"msg\":\"UAT permits only the dedicated test account\"}"); return;
|
||||
}
|
||||
boolean publicPath = (login && (req.getParameterMap().containsKey("login") || req.getParameterMap().containsKey("checkuser")))
|
||||
|| path.equals("/randcodeimage") || path.equals("/") || path.equals("")
|
||||
|| path.equals("/webpage/login/login.jsp")
|
||||
|| ((path.startsWith("/plug-in/") || path.startsWith("/style/") || path.startsWith("/images/") || path.startsWith("/css/") || path.startsWith("/js/"))
|
||||
&& path.matches(".*\\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|swf|map)$"));
|
||||
if (!publicPath) {
|
||||
HttpSession session = req.getSession(false);
|
||||
com.zzc.web.system.pojo.base.Client client = session == null ? null :
|
||||
com.zzc.web.system.manager.ClientManager.getInstance().getClient(session.getId());
|
||||
if (client == null || client.getUser() == null || !"uat_admin".equals(client.getUser().getUserName())) {
|
||||
res.sendError(401, "UAT login required"); return;
|
||||
}
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user