diff --git a/controlpanel/api/models/apps3bucket.py b/controlpanel/api/models/apps3bucket.py index 824a74c00..9cd5d44d4 100644 --- a/controlpanel/api/models/apps3bucket.py +++ b/controlpanel/api/models/apps3bucket.py @@ -42,12 +42,6 @@ def __repr__(self): def grant_bucket_access(self): tasks.S3BucketGrantToApp(self, self.current_user).create_task() - # cluster.App(self.app).grant_bucket_access( - # self.s3bucket.arn, - # self.access_level, - # self.resources, - # ) def revoke_bucket_access(self): - tasks.S3BucketRevokeAppAccess(self).create_task() - # cluster.App(self.app).revoke_bucket_access(self.s3bucket.arn) + tasks.S3BucketRevokeAppAccess(self, self.current_user).create_task() diff --git a/controlpanel/api/models/users3bucket.py b/controlpanel/api/models/users3bucket.py index 2832058d8..7e5cfbec3 100644 --- a/controlpanel/api/models/users3bucket.py +++ b/controlpanel/api/models/users3bucket.py @@ -48,4 +48,7 @@ def grant_bucket_access(self): tasks.S3BucketGrantToUser(self, self.current_user).create_task() def revoke_bucket_access(self): - tasks.S3BucketRevokeUserAccess(self).create_task() + # TODO when soft delete is added, this should be updated to use the user that + # has deleted the parent S3bucket to ensure we store the user that has sent the + # task in the case of cascading deletes + tasks.S3BucketRevokeUserAccess(self, self.current_user).create_task() diff --git a/controlpanel/frontend/views/app.py b/controlpanel/frontend/views/app.py index 015864244..d009bcd74 100644 --- a/controlpanel/frontend/views/app.py +++ b/controlpanel/frontend/views/app.py @@ -312,6 +312,11 @@ class RevokeAppAccess(OIDCLoginRequiredMixin, PermissionRequiredMixin, DeleteVie model = AppS3Bucket permission_required = "api.remove_app_bucket" + def get_object(self, queryset=None): + obj = super().get_object(queryset=queryset) + obj.current_user = self.request.user + return obj + def get_success_url(self): messages.success(self.request, "Successfully disconnected data source") return reverse_lazy("manage-app", kwargs={"pk": self.object.app.id}) diff --git a/controlpanel/frontend/views/datasource.py b/controlpanel/frontend/views/datasource.py index 77e552cf0..5099089ea 100644 --- a/controlpanel/frontend/views/datasource.py +++ b/controlpanel/frontend/views/datasource.py @@ -293,6 +293,11 @@ class RevokeAccess(OIDCLoginRequiredMixin, PermissionRequiredMixin, DeleteView): model = UserS3Bucket permission_required = "api.destroy_users3bucket" + def get_object(self, queryset=None): + obj = super().get_object(queryset=queryset) + obj.current_user = self.request.user + return obj + def get_success_url(self): messages.success(self.request, "Successfully revoked access") return reverse_lazy("manage-datasource", kwargs={"pk": self.object.s3bucket.id})