Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ignore GET

  • Loading branch information...
commit 17d06aebe641ca862181c32cebadee0510e56ebe 1 parent e6ef0a1
@wraithan wraithan authored
Showing with 15 additions and 6 deletions.
  1. +15 −6 src/hydra/api.py
View
21 src/hydra/api.py
@@ -92,6 +92,19 @@ def get_whitelist(self):
return r.smembers("%s:whitelist" % self.redis_slug)
+class CustomBasicAuthentication(BasicAuthentication):
+ def is_authenticated(self, request, **kwargs):
+ if request.method == 'GET':
+ return True
+ return (super(CustomBasicAuthentication, self)
+ .is_authenticated(request, **kwargs))
+
+ def get_identifier(self, request):
+ if request.method == 'GET':
+ return 'anon'
+ return request.user.username
+
+
class NonModelAuthorization(Authorization):
def is_authorized(self, request, object=None):
if request.method == 'GET':
@@ -100,10 +113,6 @@ def is_authorized(self, request, object=None):
return True
return False
- def get_identifier(self, request):
- if request.method == 'GET':
- return 'anon'
- return request.user.username
class ProjectResource(Resource):
"""
@@ -123,7 +132,7 @@ class Meta:
resource_name = "project"
object_class = RedisProject
authorization = NonModelAuthorization()
- authentication = BasicAuthentication()
+ authentication = CustomBasicAuthentication()
def get_resource_uri(self, bundle_or_obj):
try:
@@ -303,7 +312,7 @@ class RedirectResource(Resource):
class Meta:
object_class = RedisRedirect
authorization = NonModelAuthorization()
- authentication = BasicAuthentication()
+ authentication = CustomBasicAuthentication()
validation = URLValidation()
def get_resource_uri(self, bundle_or_obj):
Please sign in to comment.
Something went wrong with that request. Please try again.