[Patchew-devel] [PATCH v5 1/6] Handling cookies to use REST api

Shubham Jain shubhamjain7495 at gmail.com
Thu Jul 12 04:21:15 UTC 2018


- Disabled CSRF authentication until OAuth authentication, since DRF leads to csrf error while handling sessionauthentication.
---
 api/rest.py | 6 ++++++
 patchew-cli | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/api/rest.py b/api/rest.py
index 9ec0ae8..45dab6e 100644
--- a/api/rest.py
+++ b/api/rest.py
@@ -25,6 +25,12 @@ from rest_framework.response import Response
 import rest_framework
 from mbox import addr_db_to_rest, MboxMessage
 from rest_framework.parsers import JSONParser, BaseParser
+from rest_framework.authentication import SessionAuthentication
+
+class CsrfExemptSessionAuthentication(SessionAuthentication):
+
+    def enforce_csrf(self, request):
+        return  # To not perform the csrf check previously happening
 
 SEARCH_PARAM = 'q'
 
diff --git a/patchew-cli b/patchew-cli
index 174d1e6..9e1fd22 100755
--- a/patchew-cli
+++ b/patchew-cli
@@ -91,7 +91,7 @@ class SubCommand(object):
         else:
             r = None
         return r
-
+        
     def do(self, args, argv):
         """Do command"""
         print("Not implemented")
-- 
2.15.1 (Apple Git-101)




More information about the Patchew-devel mailing list