yunojuno / django-request-token

Django app that uses JWT to manage one-time and expiring tokens to protected URLs. Not related to DRF.
MIT License
47 stars 23 forks source link

Look in request.body/GET/POST for request token #30

Closed tim-mccurrach closed 5 years ago

tim-mccurrach commented 5 years ago

What has changed For GET requests, nothing has changed. For POST requests, instead of looking in request.POST the middleware now looks in request.GET, request.body then request.POST (in that order).

Why has this changed This allows AJAX requests to be made to views that require a request_token, since request.POST is empty if content-type is 'application/json'. We are also checking request.GET since it means we can put the request-token in the url for the POST action, and don't have to pass it down, and add it to the body.