Skip to content

Commit

Permalink
Fix to handle null csrfToken in session
Browse files Browse the repository at this point in the history
  • Loading branch information
zgary committed Oct 10, 2018
1 parent c573c55 commit b274b92
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dspace-api/src/main/java/org/dspace/app/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,12 @@ public static void validateCsrf(HttpServletRequest request) throws AuthorizeExce
HttpSession session = request.getSession();
String storedToken = (String) session.getAttribute("csrfToken");
String formToken = request.getParameter("csrf_token");
if (!storedToken.equals(formToken)) {
throw new AuthorizeException("CSRF Token is Invalid");
if (storedToken == null) {
throw new AuthorizeException("CSRF Token cannot be null");
} else {
if (!storedToken.equals(formToken)) {
throw new AuthorizeException("CSRF Token is Invalid");
}
}
}
}

0 comments on commit b274b92

Please sign in to comment.