mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 15:10:27 +00:00
feat: Implement apikeys/<id> endpoint from swagger spec. (#864)
This commit is contained in:
parent
718b41e3d1
commit
54b257768f
@ -391,6 +391,23 @@ def api_get_apikeys(domain_name):
|
||||
return jsonify(apikey_schema.dump(apikeys)), 200
|
||||
|
||||
|
||||
@api_bp.route('/pdnsadmin/apikeys/<int:apikey_id>', methods=['GET'])
|
||||
@api_basic_auth
|
||||
def api_get_apikey(apikey_id):
|
||||
apikey = ApiKey.query.get(apikey_id)
|
||||
|
||||
if not apikey:
|
||||
abort(404)
|
||||
|
||||
current_app.logger.debug(current_user.role.name)
|
||||
|
||||
if current_user.role.name not in ['Administrator', 'Operator']:
|
||||
if apikey_id not in [a.id for a in get_user_apikeys()]:
|
||||
raise DomainAccessForbidden()
|
||||
|
||||
return jsonify(apikey_schema.dump([apikey])[0]), 200
|
||||
|
||||
|
||||
@api_bp.route('/pdnsadmin/apikeys/<int:apikey_id>', methods=['DELETE'])
|
||||
@api_basic_auth
|
||||
def api_delete_apikey(apikey_id):
|
||||
|
@ -905,6 +905,8 @@ paths:
|
||||
description: OK.
|
||||
schema:
|
||||
$ref: '#/definitions/ApiKey'
|
||||
'403':
|
||||
description: 'The authenticated user has User role and is not allowed on any of the domains assigned to the key'
|
||||
'404':
|
||||
description: 'Not found. The ApiKey with the specified apikey_id does not exist'
|
||||
schema:
|
||||
|
Loading…
Reference in New Issue
Block a user