Django: Generate new CSRF token per request/form

后端 未结 3 1588
眼角桃花
眼角桃花 2021-02-02 17:17

Can we change CSRF token per-form request or even per-request instead of same token for one active session?

3条回答
  •  既然无缘
    2021-02-02 17:49

    And if you want to use it in a middleware:

    from django.middleware.csrf import rotate_token
    
    class CSRFRefresh(object):
        def process_response(self, request, response):
            rotate_token(request)
            return response
    

提交回复
热议问题