Skip to content

Commit

Permalink
mgr/dashboard: Unable to change rgw subuser permission
Browse files Browse the repository at this point in the history
Tried to edit the permission of a subuser but once changed the permission, edited permission not seen in user info of UI(ceph dashboard) and from CLI as well

Fixes:https://tracker.ceph.com/issues/57805
Signed-off-by: Aashish Sharma <[email protected]>
  • Loading branch information
aaSharma14 committed Oct 11, 2022
1 parent b73279e commit 0b3bdbb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
4 changes: 2 additions & 2 deletions qa/tasks/mgr/dashboard/test_rgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def test_create_swift(self):
'access': 'readwrite',
'key_type': 'swift'
})
self.assertStatus(201)
self.assertStatus(200)
data = self.jsonBody()
subuser = self.find_object_in_list('id', 'teuth-test-user:tux', data)
self.assertIsInstance(subuser, object)
Expand All @@ -827,7 +827,7 @@ def test_create_s3(self):
'access_key': 'yyy',
'secret_key': 'xxx'
})
self.assertStatus(201)
self.assertStatus(200)
data = self.jsonBody()
subuser = self.find_object_in_list('id', 'teuth-test-user:hugo', data)
self.assertIsInstance(subuser, object)
Expand Down
35 changes: 26 additions & 9 deletions src/pybind/mgr/dashboard/controllers/rgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,32 @@ def set_quota(self, uid, quota_type, enabled, max_size_kb, max_objects, daemon_n
def create_subuser(self, uid, subuser, access, key_type='s3',
generate_secret='true', access_key=None,
secret_key=None, daemon_name=None):
return self.proxy(daemon_name, 'PUT', 'user', {
'uid': uid,
'subuser': subuser,
'key-type': key_type,
'access': access,
'generate-secret': generate_secret,
'access-key': access_key,
'secret-key': secret_key
})
# pylint: disable=R1705
subusr_array = []
user = json.loads(self.get(uid, daemon_name)) # type: ignore
subusers = user["subusers"]
for sub_usr in subusers:
subusr_array.append(sub_usr["id"])
if subuser in subusr_array:
return self.proxy(daemon_name, 'POST', 'user', {
'uid': uid,
'subuser': subuser,
'key-type': key_type,
'access': access,
'generate-secret': generate_secret,
'access-key': access_key,
'secret-key': secret_key
})
else:
return self.proxy(daemon_name, 'PUT', 'user', {
'uid': uid,
'subuser': subuser,
'key-type': key_type,
'access': access,
'generate-secret': generate_secret,
'access-key': access_key,
'secret-key': secret_key
})

@RESTController.Resource(method='DELETE', path='/subuser/{subuser}', status=204)
def delete_subuser(self, uid, subuser, purge_keys='true', daemon_name=None):
Expand Down

0 comments on commit 0b3bdbb

Please sign in to comment.