CORD-2922 require authentication for all XOS APIs
Change-Id: Ie1d5ca8a36fa2ba68bf581bd90f2e72d6c78fa20
diff --git a/xos/coreapi/apihelper.py b/xos/coreapi/apihelper.py
index 3bb2abb..cef1327 100644
--- a/xos/coreapi/apihelper.py
+++ b/xos/coreapi/apihelper.py
@@ -612,7 +612,7 @@
log.exception("Exception in apihelper.filter")
raise
- def authenticate(self, context, required=False):
+ def authenticate(self, context, required=True):
for (k, v) in context.invocation_metadata():
if (k.lower() == "authorization"):
(method, auth) = v.split(" ", 1)
@@ -633,10 +633,10 @@
raise XOSPermissionDenied(
"failed to authenticate token %s" % v)
user = User.objects.get(id=id)
- print "authenticated sessionid %s as %s" % (v, user)
+ log.info("authenticated sessionid %s as %s" % (v, user))
return user
if required:
- raise XOSPermissionDenied("This API requires authentication")
+ raise XOSNotAuthenticated("This API requires authentication")
return None