From 4b7a55c89f1031e5d599ca355dae767ec226f127 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Fri, 21 Aug 2015 16:08:53 -0700 Subject: [PATCH] Fixing issue with a certificate with no role not being viewable --- lemur/certificates/views.py | 13 ++++++------- lemur/utils.py | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lemur/certificates/views.py b/lemur/certificates/views.py index 3e10b7fb..7cde93bc 100644 --- a/lemur/certificates/views.py +++ b/lemur/certificates/views.py @@ -446,14 +446,13 @@ class CertificatePrivateKey(AuthenticatedResource): role = role_service.get_by_name(cert.owner) - if role: - permission = ViewKeyPermission(certificate_id, role.name) + permission = ViewKeyPermission(certificate_id, getattr(role, 'name', None)) - if permission.can(): - response = make_response(jsonify(key=cert.private_key), 200) - response.headers['cache-control'] = 'private, max-age=0, no-cache, no-store' - response.headers['pragma'] = 'no-cache' - return response + if permission.can(): + response = make_response(jsonify(key=cert.private_key), 200) + response.headers['cache-control'] = 'private, max-age=0, no-cache, no-store' + response.headers['pragma'] = 'no-cache' + return response return dict(message='You are not authorized to view this key'), 403 diff --git a/lemur/utils.py b/lemur/utils.py index 1ea73759..41b054c3 100644 --- a/lemur/utils.py +++ b/lemur/utils.py @@ -17,4 +17,5 @@ def get_key(): try: return current_app.config.get('LEMUR_ENCRYPTION_KEY').strip() except RuntimeError: + print("No Encryption Key Found") return ''