Fixing issue with a certificate with no role not being viewable
This commit is contained in:
parent
4b9a05198c
commit
4b7a55c89f
|
@ -446,14 +446,13 @@ class CertificatePrivateKey(AuthenticatedResource):
|
||||||
|
|
||||||
role = role_service.get_by_name(cert.owner)
|
role = role_service.get_by_name(cert.owner)
|
||||||
|
|
||||||
if role:
|
permission = ViewKeyPermission(certificate_id, getattr(role, 'name', None))
|
||||||
permission = ViewKeyPermission(certificate_id, role.name)
|
|
||||||
|
|
||||||
if permission.can():
|
if permission.can():
|
||||||
response = make_response(jsonify(key=cert.private_key), 200)
|
response = make_response(jsonify(key=cert.private_key), 200)
|
||||||
response.headers['cache-control'] = 'private, max-age=0, no-cache, no-store'
|
response.headers['cache-control'] = 'private, max-age=0, no-cache, no-store'
|
||||||
response.headers['pragma'] = 'no-cache'
|
response.headers['pragma'] = 'no-cache'
|
||||||
return response
|
return response
|
||||||
|
|
||||||
return dict(message='You are not authorized to view this key'), 403
|
return dict(message='You are not authorized to view this key'), 403
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,5 @@ def get_key():
|
||||||
try:
|
try:
|
||||||
return current_app.config.get('LEMUR_ENCRYPTION_KEY').strip()
|
return current_app.config.get('LEMUR_ENCRYPTION_KEY').strip()
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
|
print("No Encryption Key Found")
|
||||||
return ''
|
return ''
|
||||||
|
|
Loading…
Reference in New Issue