how to access POST data inside tastypie custom Authentication

前端 未结 4 1265
北荒
北荒 2021-01-02 04:58

I\'m trying to write custom Authentication in tastypie. Basically, I want to do the authentication using the post parameters and I don\'t want to use the django auth at all,

4条回答
  •  再見小時候
    2021-01-02 05:21

    You say you need custom auth which is fine but please consider using the Authorization header instead. By using POST you force Django to parse the entire payload assuming the data is either urlencoded or multipart form encoded. This effectively makes it impossible to use non-form payloads such as JSON or YAML.

    class MyAuthentication(Authentication):
        def is_authenticated(self, request, **kwargs):
            auth_info = request.META.get('HTTP_AUTHORIZATION')
            # ...
    

提交回复
热议问题