question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please document using csrf_exempt for read-only POST APIs

See original GitHub issue

I have a ReactJS application that is hosted on a separate domain from my Django app. But the library (Apollo) currently only makes requests with POST. Since I have no mutations in my Graphene implementations, it’s pretty safe for me to use csrf_exempt for my GraphQL view.

Would you be able to add that to your documentation somewhere so that people know this is an option. Would you also be able to confirm that I’m correct in my deduction? 😃 If it’s still possible to write to GraphQL without mutations, I’ll need to look for a different solution.

Thanks!!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
phaltcommented, Jun 25, 2019

Simply wrapping the view in a csrf_exempt is enough but yes, we should add this to the docs:

from django.views.decorators.csrf import csrf_exempt

url(r'^graphql', csrf_exempt(GraphQLView.as_view(schema=schema)), name='graphql',),
0reactions
stale[bot]commented, Nov 22, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should we check CSRF token for read only actions
If yes please share an example how action which only performs read only operations can be exploited using CSRF. web · csrf ·...
Read more >
CSRF vulnerabilities: How to exploit and how to defend
Read-only GET requests. The first line of defense is to never allow GET request to perform CREATE / UPDATE / DELETE operations. SameSite...
Read more >
CSRF token validation failed - SAP Community
Hello Expert,. While I am trying out the API Sales Order (A2X) by posting entity A_SalesOrder in API Hub,. Sandbox system returns the...
Read more >
Cross Site Request Forgery protection - Django documentation
Requests via 'unsafe' methods, such as POST, PUT, and DELETE, can then be protected by the steps outlined in How to use Django's...
Read more >
Configuring CSRF (Cross-Site Request Forgery) prevention in ...
In most cases, the browser checks your server's CORS policy by sending a preflight request before sending the actual operation. This is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found