How to secure Ajax link requests?

前端 未结 8 1027
刺人心
刺人心 2020-12-08 04:04

Imagine the next scenario: a user wants to register to a webpage and fills a form. While he is filling the form, jQuery keeps checking through a regular expression if fields

8条回答
  •  猫巷女王i
    2020-12-08 04:52

    One approach to resolve this problem could be this:

    Suppose you have ajax request calling your server to receive a response from a particular user or client. You can have a table in your database where you provide a unique token for every user or hash value that can be checked every time user makes an ajax request to the server. If the token value matches the user request value than he is a genuine user. You can also record his number of request on the table to ensure he is making legitimate requests. I acknowledge the fact that it may slow down your app performance, but it will be safe option to consider. Note: you need to retrieve the token on your HTML page to send it with ajax.

    Please comment to know more. I have been using this approach and there is no problem until now.

    Example:

提交回复
热议问题