on-internet
← Community

CSRF token generation issue

Stack Overflow ·

To prevent CSRF below were the steps i have followed: 1. First time when request comes(to loginfilter) session is null, create a session add token(randome number) to this new session by using setAttribute() and redirect to login.jsp screen using dispatcher.forward. 2. in login.jsp screen use getAttribute() store the token in the hidden filed. 3. on submit of login.jsp first request will come to loginfilter, here compare the token from the request with the token in the session, if matches then proceed with executing the action class. otherwise generate the new token for the same session and red

Comments

Sign in or sign up to comment and upvote.

No comments yet.