mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-04-19 10:17:31 +00:00
Tweaks to allow user apikey usage with powerdns terraform provider (#845)
This commit is contained in:
parent
942482b706
commit
c6e0293177
@ -236,7 +236,7 @@ def apikey_can_access_domain(f):
|
|||||||
apikey = g.apikey
|
apikey = g.apikey
|
||||||
if g.apikey.role.name not in ['Administrator', 'Operator']:
|
if g.apikey.role.name not in ['Administrator', 'Operator']:
|
||||||
domains = apikey.domains
|
domains = apikey.domains
|
||||||
zone_id = kwargs.get('zone_id')
|
zone_id = kwargs.get('zone_id').rstrip(".")
|
||||||
domain_names = [item.name for item in domains]
|
domain_names = [item.name for item in domains]
|
||||||
|
|
||||||
if zone_id not in domain_names:
|
if zone_id not in domain_names:
|
||||||
|
@ -913,21 +913,12 @@ def api_zone_forward(server_id, zone_id):
|
|||||||
created_by=g.apikey.description)
|
created_by=g.apikey.description)
|
||||||
history.add()
|
history.add()
|
||||||
elif request.method == 'DELETE':
|
elif request.method == 'DELETE':
|
||||||
history = History(msg='Deleted zone {0}'.format(domain.name),
|
history = History(msg='Deleted zone {0}'.format(zone_id),
|
||||||
detail='',
|
detail='',
|
||||||
created_by=g.apikey.description)
|
created_by=g.apikey.description)
|
||||||
history.add()
|
history.add()
|
||||||
return resp.content, resp.status_code, resp.headers.items()
|
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'])
|
@api_bp.route('/servers/<path:subpath>', methods=['GET', 'PUT'])
|
||||||
@apikey_auth
|
@apikey_auth
|
||||||
@apikey_is_admin
|
@apikey_is_admin
|
||||||
@ -977,6 +968,18 @@ def api_get_zones(server_id):
|
|||||||
return resp.content, resp.status_code, resp.headers.items()
|
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
|
# The endpoint to snychronize Domains in background
|
||||||
@api_bp.route('/sync_domains', methods=['GET'])
|
@api_bp.route('/sync_domains', methods=['GET'])
|
||||||
@apikey_auth
|
@apikey_auth
|
||||||
|
Loading…
x
Reference in New Issue
Block a user