How to POST webhook with CSRF? #18798
Replies: 1 comment 2 replies
-
Problem solved. I had to set my custom remote auth backend to skip any requests starting with |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm looking for clarity on exactly what is required to satisfy Netbox / Django CSRF requirements.
I'm trying to run a custom script via the API and I'm getting this error:
I'm providing an API token in the
Authorization
header, so I don't thinkReferer
should be necessary. As evidence of that, if I POST the request on localhost:80 then it works fine, like this:But when I run through my TLS gateway, it fails.
The Django docs say a CSRF cookie must be present, and they don't mention any exceptions about webhooks like this. But if the cookie is strictly required, then why does it work on localhost?
To debug this, tried adding a custom middleware that logs the entire
request
object, to compare all the headers from the local request vs TLS, and I can't find any meaningful differences. I even tried removingdjango.middleware.csrf.CsrfViewMiddleware
from settings.py and that didn't help! I'm stumped by that, as I thought this error must be coming from that class.Beta Was this translation helpful? Give feedback.
All reactions