Struts2 token interceptor: CSRF protection

后端 未结 1 430
南旧
南旧 2021-02-03 13:22

I am trying to protect my web application from CSRF attacks by using struts token interceptor.

The problem I am facing right now is our JSP pages makes more than one cal

相关标签:
1条回答
  • 2021-02-03 13:47

    You can use the code in my answer for Unable to implement Struts 2 token interceptor with hyperlink to create an action that returns a token. You can use any of the results stream or json or dispatcher to return a token as a Ajax success callback result. You can find an example in jQuery Ajax - issue returning JSON value. Now you can use the token to make your Ajax requests. Each time you need to make a new request you should call a token action to get a new token. Use the token as a parameter to your request and put the token interceptor in front of your actions.

    0 讨论(0)
提交回复
热议问题