This question came across my mind when I sent an ajax request from html to a backend django server and forgot to add a csrf token to the request payload and recieved this error.
403 error means that the request was unauthorized.
I know that while using django, using csrf token is neccessary. But lets take an example where I am using jwt tokens for user authentication and csrf token for request authorization. What will happen first? Authentication or authorization?
The simple answer I found while surfing the web was the Authentication ALWAYS occurs before Authorization. But this statement seems contrary to the error I recieved where the request was unauthorized even before the authentication process started. So what is happening here?
Extending my initial question, if I securely use JWT tokens, is using csrf token for protection against csrf attacks really neccessary (talking in general, not specific to django)? Won't JWT serve the purpose for both? What is the industry standard in such a use case?
403 - Unauthorized
means that either the server cannot identify you properly (authentication) or it could but you have no authorization to use the resource.