mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-07 10:55:40 +00:00
feat: enable_api_rr_history setting (#998)
* feat: introduce enable_api_rr_history setting to disable api record changes
This commit is contained in:
parent
20b866a784
commit
e7d5a3aba0
@ -29,6 +29,7 @@ class Setting(db.Model):
|
|||||||
'allow_user_remove_domain': False,
|
'allow_user_remove_domain': False,
|
||||||
'allow_user_view_history': False,
|
'allow_user_view_history': False,
|
||||||
'bg_domain_updates': False,
|
'bg_domain_updates': False,
|
||||||
|
'enable_api_rr_history': True,
|
||||||
'site_name': 'PowerDNS-Admin',
|
'site_name': 'PowerDNS-Admin',
|
||||||
'site_url': 'http://localhost:9191',
|
'site_url': 'http://localhost:9191',
|
||||||
'session_timeout': 10,
|
'session_timeout': 10,
|
||||||
|
@ -644,7 +644,7 @@ def setting_basic():
|
|||||||
'pretty_ipv6_ptr', 'dnssec_admins_only',
|
'pretty_ipv6_ptr', 'dnssec_admins_only',
|
||||||
'allow_user_create_domain', 'allow_user_remove_domain', 'allow_user_view_history', 'bg_domain_updates', 'site_name',
|
'allow_user_create_domain', 'allow_user_remove_domain', 'allow_user_view_history', 'bg_domain_updates', 'site_name',
|
||||||
'session_timeout', 'warn_session_timeout', 'ttl_options',
|
'session_timeout', 'warn_session_timeout', 'ttl_options',
|
||||||
'pdns_api_timeout', 'verify_ssl_connections', 'verify_user_email', 'otp_field_enabled', 'custom_css'
|
'pdns_api_timeout', 'verify_ssl_connections', 'verify_user_email', 'otp_field_enabled', 'custom_css', 'enable_api_rr_history'
|
||||||
]
|
]
|
||||||
|
|
||||||
return render_template('admin_setting_basic.html', settings=settings)
|
return render_template('admin_setting_basic.html', settings=settings)
|
||||||
|
@ -979,28 +979,29 @@ def api_zone_forward(server_id, zone_id):
|
|||||||
status = resp.status_code
|
status = resp.status_code
|
||||||
if 200 <= status < 300:
|
if 200 <= status < 300:
|
||||||
current_app.logger.debug("Request to powerdns API successful")
|
current_app.logger.debug("Request to powerdns API successful")
|
||||||
if request.method in ['POST', 'PATCH'] :
|
if Setting().get('enable_api_rr_history'):
|
||||||
data = request.get_json(force=True)
|
if request.method in ['POST', 'PATCH'] :
|
||||||
for rrset_data in data['rrsets']:
|
data = request.get_json(force=True)
|
||||||
history = History(msg='{0} zone {1} record of {2}'.format(
|
for rrset_data in data['rrsets']:
|
||||||
rrset_data['changetype'].lower(), rrset_data['type'],
|
history = History(msg='{0} zone {1} record of {2}'.format(
|
||||||
rrset_data['name'].rstrip('.')),
|
rrset_data['changetype'].lower(), rrset_data['type'],
|
||||||
detail=json.dumps(data),
|
rrset_data['name'].rstrip('.')),
|
||||||
created_by=g.apikey.description,
|
detail=json.dumps(data),
|
||||||
domain_id=Domain().get_id_by_name(zone_id.rstrip('.')))
|
created_by=g.apikey.description,
|
||||||
|
domain_id=Domain().get_id_by_name(zone_id.rstrip('.')))
|
||||||
|
history.add()
|
||||||
|
elif request.method == 'DELETE':
|
||||||
|
history = History(msg='Deleted zone {0}'.format(zone_id.rstrip('.')),
|
||||||
|
detail='',
|
||||||
|
created_by=g.apikey.description,
|
||||||
|
domain_id=Domain().get_id_by_name(zone_id.rstrip('.')))
|
||||||
|
history.add()
|
||||||
|
elif request.method != 'GET':
|
||||||
|
history = History(msg='Updated zone {0}'.format(zone_id.rstrip('.')),
|
||||||
|
detail='',
|
||||||
|
created_by=g.apikey.description,
|
||||||
|
domain_id=Domain().get_id_by_name(zone_id.rstrip('.')))
|
||||||
history.add()
|
history.add()
|
||||||
elif request.method == 'DELETE':
|
|
||||||
history = History(msg='Deleted zone {0}'.format(zone_id.rstrip('.')),
|
|
||||||
detail='',
|
|
||||||
created_by=g.apikey.description,
|
|
||||||
domain_id=Domain().get_id_by_name(zone_id.rstrip('.')))
|
|
||||||
history.add()
|
|
||||||
elif request.method != 'GET':
|
|
||||||
history = History(msg='Updated zone {0}'.format(zone_id.rstrip('.')),
|
|
||||||
detail='',
|
|
||||||
created_by=g.apikey.description,
|
|
||||||
domain_id=Domain().get_id_by_name(zone_id.rstrip('.')))
|
|
||||||
history.add()
|
|
||||||
return resp.content, resp.status_code, resp.headers.items()
|
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'])
|
||||||
|
Loading…
Reference in New Issue
Block a user