superuser: proper view for approvals/keys

This commit is contained in:
Jimmy Zelinskie 2016-03-30 16:48:06 -04:00 committed by Jimmy Zelinskie
parent dff59b4a39
commit 93720bd0f4

View file

@ -478,6 +478,28 @@ class SuperUserOrganizationManagement(ApiResource):
abort(403)
def key_view(key):
return {
'name': key.name,
'kid': key.kid,
'service': key.service,
'jwk': key.jwk,
'metadata': key.metadata,
'created_date': key.created_date,
'expiration_date': key.expiration_date,
'approval': approval_view(key.approval) if key.approval is not None else None,
}
def approval_view(approval):
return {
'approver': user_view(approval.approver),
'approval_type': approval.approval_type,
'approved_date': approval.approved_date,
'notes': approval.notes,
}
@resource('/v1/superuser/keys')
@show_if(features.SUPER_USERS)
class SuperUserServiceKeyManagement(ApiResource):
@ -514,7 +536,8 @@ class SuperUserServiceKeyManagement(ApiResource):
@require_scope(scopes.SUPERUSER)
def get(self):
if SuperUserPermission().can():
return jsonify(model.service_keys.list_keys())
keys = model.service_keys.list_keys()
return jsonify({'keys': [key_view(key) for key in keys]})
abort(403)
@verify_not_prod