From ad9ac0c6dce5b2a8da72bb4860a353aeb0bd09d9 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Wed, 11 Jul 2012 14:57:55 -0400 Subject: Raise HTTP 500 if service catalog is not json. Updates the Nova API auth middleware so that it returns a HTTP 500 error if invalid JSON is found. Adds a unit test. Change-Id: I236ced13bac2164e103060e78845a410ceb6cdd4 --- nova/api/auth.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/auth.py b/nova/api/auth.py index 5191189f2..a118b271e 100644 --- a/nova/api/auth.py +++ b/nova/api/auth.py @@ -99,7 +99,12 @@ class NovaKeystoneContext(wsgi.Middleware): service_catalog = None if req.headers.get('X_SERVICE_CATALOG') is not None: - service_catalog = json.loads(req.headers.get('X_SERVICE_CATALOG')) + try: + catalog_header = req.headers.get('X_SERVICE_CATALOG') + service_catalog = json.loads(catalog_header) + except ValueError: + raise webob.exc.HTTPInternalServerError( + _('Invalid service catalog json.')) ctx = context.RequestContext(user_id, project_id, -- cgit