Skip to content

Commit

Permalink
mgr/dashboard: Prevent RGW API user deletion
Browse files Browse the repository at this point in the history
Fixes https://tracker.ceph.com/issues/24080

It's not possible to cherry-pick the changes from master because the issue has been implemented totally different there. Additionally there is no special PR for this issue in master, too. See PR #22470 if you want to see the changes in Nautilus.

Signed-off-by: Volker Theile <vtheile@suse.com>
  • Loading branch information
votdev committed Jul 26, 2018
1 parent 5eaeb92 commit ff6acf1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 22 additions & 0 deletions src/pybind/mgr/dashboard/controllers/rgw.py
Expand Up @@ -121,3 +121,25 @@ def create(self, bucket, uid):
cherrypy.response.headers['Content-Type'] = 'application/json'
cherrypy.response.status = 500
return {'detail': str(e)}


@ApiController('rgw/user')
@AuthRequired()
class RgwUser(RESTController):

def delete(self, uid):
try:
rgw_client = RgwClient.admin_instance()

# Ensure the user is not configured to access the Object Gateway.
if rgw_client.userid == uid:
raise RequestException('Unable to delete "{}" - this user '
'account is required for managing the '
'Object Gateway'.format(uid))

# Finally redirect request to the RGW proxy.
return rgw_client.proxy('DELETE', 'user', cherrypy.request.params, None)
except RequestException as e:
cherrypy.response.headers['Content-Type'] = 'application/json'
cherrypy.response.status = 500
return {'detail': str(e)}
Expand Up @@ -75,9 +75,7 @@ export class RgwUserService {
}

delete(uid: string) {
let params = new HttpParams();
params = params.append('uid', uid);
return this.http.delete(this.url, {params: params});
return this.http.delete(`api/rgw/user/${uid}`);
}

addSubuser(uid: string, subuser: string, permissions: string,
Expand Down

0 comments on commit ff6acf1

Please sign in to comment.