Open peterbe opened 9 years ago
Might not be the best solution, but you could give each route in your router a separate nosurf instance.
Many routers support adding subrouters, so you could have "api" and "www" sets of routes and protect only one of them.
Thanks. I'll try that. Do you still think it's worth keeping this issue or is grouping sub-groups of routes the solid solution?
It might not be an ideal solution, but I would not like to introduce much complexity for filtering routes in nosurf itself (separate blacklist/whitelist modes, etc.).
I have some handlers that use POST, PUT etc that I do NOT want to be protected by nosurf. These are REST API endpoints that don't need CSRF protection as you can't use them without an Auth-Token header anyway.
I can use nosurf like this:
But now my poor REST API endpoints get a Vary Cookie and a Set-Cookie too.
Can I use nosurf to protect just individual handler functions and now the whole mux thing?