obc: Do not delete user for retain policy if it is owner

When obc is deleted, the attached ceph user will be also removed
This will cause obc creation failure for the same bucket since user
was missing. With this patch the user will be retained revoking his permissions

Also removed 'GetBucketPolicy' permission from Allowed action. The same set of
permission is used for denying the owner/old user of OBC. So that in the next
obc request for the bucket, owner can set polciy for the new user

Closes: https://github.com/rook/rook/issues/5510
Signed-off-by: Jiffin Tony Thottan <thottanjiffin@gmail.com>
This commit is contained in:
Jiffin Tony Thottan committed 2020-05-27 22:58:08 +05:30
1 parent 3ffda5645a
commit 9a3ffbaab2
2 files changed
+22 -1

No files matched your search

@@ -254,6 +254,28 @@ func (p Provisioner) Revoke(ob *bktv1alpha1.ObjectBucket) error {
}
}
if bucket.Owner == p.cephUserName {
statement := NewPolicyStatement().
WithSID(p.cephUserName).
ForPrincipals(p.cephUserName).
ForResources(p.bucketName).
ForSubResources(p.bucketName).
Denies().
Actions(AllowedActions...)
if policy == nil {
policy = NewBucketPolicy(*statement)
} else {
policy = policy.ModifyBucketPolicy(*statement)
}
out, err := s3svc.PutBucketPolicy(p.bucketName, *policy)
logger.Infof("PutBucketPolicy output: %v", out)
if err != nil {
return errors.Wrap(err, "failed to update policy")
} else {
return nil
}
}
// drop policy if present
if policy != nil {
policy = policy.DropPolicyStatements(p.cephUserName)
@@ -184,7 +184,6 @@ var AllowedActions = []action{
GetBucketLocation,
GetBucketLogging,
GetBucketNotification,
GetBucketPolicy,
GetBucketTagging,
GetBucketVersioning,
GetBucketWebsite,