Skip to content

Commit

Permalink
MID-4476 fixed login page session expiration (csrf related problem)
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Feb 23, 2018
1 parent 6be4a2f commit 01d686c
Showing 1 changed file with 17 additions and 3 deletions.
Expand Up @@ -16,13 +16,13 @@

package com.evolveum.midpoint.web.security;

import org.apache.commons.lang.StringUtils;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.access.AccessDeniedHandlerImpl;
import org.springframework.security.web.csrf.CsrfException;
import org.springframework.security.web.csrf.InvalidCsrfTokenException;
import org.springframework.security.web.csrf.MissingCsrfTokenException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -57,6 +57,20 @@ private boolean isLoginLogoutRequest(HttpServletRequest req) {
}

String uri = req.getRequestURI();
return "/j_spring_security_logout".equals(uri) || "/spring_security_login".equals(uri);
return createUri(req, "/j_spring_security_logout").equals(uri)
|| createUri(req, "/spring_security_login").equals(uri);
}

private String createUri(HttpServletRequest req, String uri) {
StringBuilder sb = new StringBuilder();

ServletContext ctx = req.getServletContext();
String ctxPath = ctx.getContextPath();
if (StringUtils.isNotEmpty(ctxPath)) {
sb.append(ctxPath);
}
sb.append(uri);

return sb.toString();
}
}

0 comments on commit 01d686c

Please sign in to comment.