Open hMED22 opened 2 years ago
I also desire to transiently disable CSRF for a single request based on the request context.
One problem of this is that g.csrf_valid is internal to flask-wtf and not documented as part of the API so I don't know if it's a good idea to use it.
Likewise. An ok fix for this could be to just call it official and document it.
Instead of
CSRFProtect.exempt
that disables CSRF on a view for all requests, there should also be a way to disable it for all views based on the request context, like token authenticated requests for example.For this the docs suggest
But it doesn't feel right to disable the extension globally, plus that way
CSRFProtect.exempt
is no longer usable.I tried something like
But CSRF protection runs and returns an error response before my hook gets called.
I am now going with a subclass:
One problem of this is that
g.csrf_valid
is internal to flask-wtf and not documented as part of the API so I don't know if it's a good idea to use it.