feat: limit zone list for users on servers endpoint (#862)

This commit is contained in:
jbe-dw 2021-01-16 20:45:02 +01:00 committed by GitHub
parent dd0a5f6326
commit 718b41e3d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -971,7 +971,15 @@ def api_get_zones(server_id):
return jsonify(domain_schema.dump(domain_obj_list)), 200 return jsonify(domain_schema.dump(domain_obj_list)), 200
else: else:
resp = helper.forward_request() resp = helper.forward_request()
return resp.content, resp.status_code, resp.headers.items() if (g.apikey.role.name not in ['Administrator', 'Operator']
and resp.status_code == 200):
domain_list = [d['name']
for d in domain_schema.dump(g.apikey.domains)]
content = json.dumps([i for i in json.loads(resp.content)
if i['name'].rstrip('.') in domain_list])
return content, resp.status_code, resp.headers.items()
else:
return resp.content, resp.status_code, resp.headers.items()
@api_bp.route('/servers', methods=['GET']) @api_bp.route('/servers', methods=['GET'])