Domanda di colloquio di ErnieApp

Django REST framework provides CSRF protection. When should it be used?

Risposta di colloquio

Anonimo

15 apr 2020

CSRF should be used when using SessionAuthentication in order to make sure that only the AJAX requests from the same context as the API are allowed. If you want your API to be publicly available you should probably look at TokenAuthentication or implement your own authentication backend.