Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ignore GET

  • Loading branch information...
commit 17d06aebe641ca862181c32cebadee0510e56ebe 1 parent e6ef0a1
Wraithan (Chris McDonald) authored August 19, 2012

Showing 1 changed file with 15 additions and 6 deletions. Show diff stats Hide diff stats

  1. 21  src/hydra/api.py
21  src/hydra/api.py
@@ -92,6 +92,19 @@ def get_whitelist(self):
92 92
         return r.smembers("%s:whitelist" % self.redis_slug)
93 93
 
94 94
 
  95
+class CustomBasicAuthentication(BasicAuthentication):
  96
+    def is_authenticated(self, request, **kwargs):
  97
+        if request.method == 'GET':
  98
+            return True
  99
+        return (super(CustomBasicAuthentication, self)
  100
+                .is_authenticated(request, **kwargs))
  101
+
  102
+    def get_identifier(self, request):
  103
+        if request.method == 'GET':
  104
+            return 'anon'
  105
+        return request.user.username
  106
+
  107
+
95 108
 class NonModelAuthorization(Authorization):
96 109
     def is_authorized(self, request, object=None):
97 110
         if request.method == 'GET':
@@ -100,10 +113,6 @@ def is_authorized(self, request, object=None):
100 113
             return True
101 114
         return False
102 115
 
103  
-    def get_identifier(self, request):
104  
-        if request.method == 'GET':
105  
-            return 'anon'
106  
-        return request.user.username
107 116
 
108 117
 class ProjectResource(Resource):
109 118
     """
@@ -123,7 +132,7 @@ class Meta:
123 132
         resource_name = "project"
124 133
         object_class = RedisProject
125 134
         authorization = NonModelAuthorization()
126  
-        authentication = BasicAuthentication()
  135
+        authentication = CustomBasicAuthentication()
127 136
 
128 137
     def get_resource_uri(self, bundle_or_obj):
129 138
         try:
@@ -303,7 +312,7 @@ class RedirectResource(Resource):
303 312
     class Meta:
304 313
         object_class = RedisRedirect
305 314
         authorization = NonModelAuthorization()
306  
-        authentication = BasicAuthentication()
  315
+        authentication = CustomBasicAuthentication()
307 316
         validation = URLValidation()
308 317
 
309 318
     def get_resource_uri(self, bundle_or_obj):

0 notes on commit 17d06ae

Please sign in to comment.
Something went wrong with that request. Please try again.