superuser: proper view for approvals/keys
This commit is contained in:
parent
dff59b4a39
commit
93720bd0f4
1 changed files with 24 additions and 1 deletions
|
@ -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
|
||||
|
|
Reference in a new issue