Tweaks to allow user apikey usage with powerdns terraform provider (#845)

This commit is contained in:
WhatshallIbreaktoday 2020-12-07 22:06:37 +01:00 committed by GitHub
parent 942482b706
commit c6e0293177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -236,7 +236,7 @@ def apikey_can_access_domain(f):
apikey = g.apikey
if g.apikey.role.name not in ['Administrator', 'Operator']:
domains = apikey.domains
zone_id = kwargs.get('zone_id')
zone_id = kwargs.get('zone_id').rstrip(".")
domain_names = [item.name for item in domains]
if zone_id not in domain_names:

View File

@ -913,21 +913,12 @@ def api_zone_forward(server_id, zone_id):
created_by=g.apikey.description)
history.add()
elif request.method == 'DELETE':
history = History(msg='Deleted zone {0}'.format(domain.name),
history = History(msg='Deleted zone {0}'.format(zone_id),
detail='',
created_by=g.apikey.description)
history.add()
return resp.content, resp.status_code, resp.headers.items()
@api_bp.route('/servers', methods=['GET'])
@apikey_auth
@apikey_is_admin
def api_server_forward():
resp = helper.forward_request()
return resp.content, resp.status_code, resp.headers.items()
@api_bp.route('/servers/<path:subpath>', methods=['GET', 'PUT'])
@apikey_auth
@apikey_is_admin
@ -977,6 +968,18 @@ def api_get_zones(server_id):
return resp.content, resp.status_code, resp.headers.items()
@api_bp.route('/servers', methods=['GET'])
@apikey_auth
def api_server_forward():
resp = helper.forward_request()
return resp.content, resp.status_code, resp.headers.items()
@api_bp.route('/servers/<string:server_id>', methods=['GET'])
@apikey_auth
def api_server_config_forward(server_id):
resp = helper.forward_request()
return resp.content, resp.status_code, resp.headers.items()
# The endpoint to snychronize Domains in background
@api_bp.route('/sync_domains', methods=['GET'])
@apikey_auth