Search code examples
sails.jscsrf

How can i enable csrf for GET requests in SAILS js


I want to restrict access to some of the GET request routes in my application using csrf.js? How do i achieve this? As per docs csrf can be done only for NON-GET requests.


Solution

  • I think you are misunderstanding what Cross-Site Request Forgery Tokens (CSRF) are. They are to validate that data sent to a server is coming from where it says it is coming from.

    I believe that what you are wanting is more of an API key/token type situation, in which case you can easily use Sails policies to validate a key against one that you have stored somewhere.