Skip to content

Commit a42eef3

Browse files
authored
Support wildcard list actions (#2520)
1 parent bbf115d commit a42eef3

File tree

7 files changed

+39
-11
lines changed

7 files changed

+39
-11
lines changed

portal-ui/src/common/SecureComponent/permissions.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const IAM_ROLES = {
2424
export const IAM_SCOPES = {
2525
S3_STAR_BUCKET: "s3:*Bucket",
2626
S3_LIST_BUCKET: "s3:ListBucket",
27+
S3_ALL_LIST_BUCKET: "s3:List*",
2728
S3_GET_BUCKET_POLICY: "s3:GetBucketPolicy",
2829
S3_PUT_BUCKET_POLICY: "s3:PutBucketPolicy",
2930
S3_GET_OBJECT: "s3:GetObject",
@@ -238,7 +239,10 @@ export const IAM_PERMISSIONS = {
238239
IAM_SCOPES.S3_PUT_OBJECT,
239240
IAM_SCOPES.S3_DELETE_OBJECT,
240241
],
241-
[IAM_ROLES.BUCKET_VIEWER]: [IAM_SCOPES.S3_LIST_BUCKET],
242+
[IAM_ROLES.BUCKET_VIEWER]: [
243+
IAM_SCOPES.S3_LIST_BUCKET,
244+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
245+
],
242246
[IAM_ROLES.BUCKET_ADMIN]: [
243247
IAM_SCOPES.S3_ALL_ACTIONS,
244248
IAM_SCOPES.ADMIN_ALL_ACTIONS,
@@ -585,4 +589,7 @@ export const deleteBucketPermissions = [
585589
IAM_SCOPES.S3_FORCE_DELETE_BUCKET,
586590
];
587591

588-
export const browseBucketPermissions = [IAM_SCOPES.S3_LIST_BUCKET];
592+
export const browseBucketPermissions = [
593+
IAM_SCOPES.S3_LIST_BUCKET,
594+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
595+
];

portal-ui/src/screens/Console/Buckets/BucketDetails/BrowserHandler.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ const BrowserHandler = () => {
381381

382382
const displayListObjects = hasPermission(bucketName, [
383383
IAM_SCOPES.S3_LIST_BUCKET,
384+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
384385
]);
385386

386387
// Common objects list
@@ -529,7 +530,7 @@ const BrowserHandler = () => {
529530
<Fragment>
530531
{!versionsMode ? (
531532
<SecureComponent
532-
scopes={[IAM_SCOPES.S3_LIST_BUCKET]}
533+
scopes={[IAM_SCOPES.S3_LIST_BUCKET, IAM_SCOPES.S3_ALL_LIST_BUCKET]}
533534
resource={bucketName}
534535
errorProps={{ disabled: true }}
535536
>

portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ const ListBuckets = ({ classes }: IListBucketsProps) => {
220220
};
221221

222222
const canCreateBucket = hasPermission("*", [IAM_SCOPES.S3_CREATE_BUCKET]);
223-
const canListBuckets = hasPermission("*", [IAM_SCOPES.S3_LIST_BUCKET]);
223+
const canListBuckets = hasPermission("*", [
224+
IAM_SCOPES.S3_LIST_BUCKET,
225+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
226+
]);
224227

225228
return (
226229
<Fragment>
@@ -453,7 +456,10 @@ const ListBuckets = ({ classes }: IListBucketsProps) => {
453456
<Fragment>
454457
<br />
455458
{permissionTooltipHelper(
456-
[IAM_SCOPES.S3_LIST_BUCKET],
459+
[
460+
IAM_SCOPES.S3_LIST_BUCKET,
461+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
462+
],
457463
"view the buckets on this server"
458464
)}
459465
<br />

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ const ListObjects = () => {
955955
disabled={
956956
!hasPermission(bucketName, [
957957
IAM_SCOPES.S3_LIST_BUCKET,
958+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
958959
]) || rewindEnabled
959960
}
960961
/>
@@ -1016,7 +1017,10 @@ const ListObjects = () => {
10161017
</Fragment>
10171018
) : (
10181019
<SecureComponent
1019-
scopes={[IAM_SCOPES.S3_LIST_BUCKET]}
1020+
scopes={[
1021+
IAM_SCOPES.S3_LIST_BUCKET,
1022+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
1023+
]}
10201024
resource={bucketName}
10211025
errorProps={{ disabled: true }}
10221026
>
@@ -1050,7 +1054,10 @@ const ListObjects = () => {
10501054
</SecureComponent>
10511055
)}
10521056
<SecureComponent
1053-
scopes={[IAM_SCOPES.S3_LIST_BUCKET]}
1057+
scopes={[
1058+
IAM_SCOPES.S3_LIST_BUCKET,
1059+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
1060+
]}
10541061
resource={bucketName}
10551062
errorProps={{ disabled: true }}
10561063
>

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjectsTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ const ListObjectsTable = () => {
114114

115115
const displayListObjects = hasPermission(bucketName, [
116116
IAM_SCOPES.S3_LIST_BUCKET,
117+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
117118
]);
118119

119120
const filteredRecords = records.filter((b: BucketObjectItem) => {
@@ -221,7 +222,7 @@ const ListObjectsTable = () => {
221222
customEmptyMessage={
222223
!displayListObjects
223224
? permissionTooltipHelper(
224-
[IAM_SCOPES.S3_LIST_BUCKET],
225+
[IAM_SCOPES.S3_LIST_BUCKET, IAM_SCOPES.S3_ALL_LIST_BUCKET],
225226
"view Objects in this bucket"
226227
)
227228
: `This location is empty${

portal-ui/src/screens/Console/ObjectBrowser/OBBucketList.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ const OBListBuckets = () => {
129129

130130
const hasBuckets = records.length > 0;
131131

132-
const canListBuckets = hasPermission("*", [IAM_SCOPES.S3_LIST_BUCKET]);
132+
const canListBuckets = hasPermission("*", [
133+
IAM_SCOPES.S3_LIST_BUCKET,
134+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
135+
]);
133136

134137
const tableActions = [
135138
{
@@ -276,7 +279,10 @@ const OBListBuckets = () => {
276279
<Fragment>
277280
<br />
278281
{permissionTooltipHelper(
279-
[IAM_SCOPES.S3_LIST_BUCKET],
282+
[
283+
IAM_SCOPES.S3_LIST_BUCKET,
284+
IAM_SCOPES.S3_ALL_LIST_BUCKET,
285+
],
280286
"view the buckets on this server"
281287
)}
282288
<br />

portal-ui/tests/utils/elements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export const table = Selector(".ReactVirtualized__Table");
141141
export const bucketsTableDisabled = Selector("#object-list-wrapper")
142142
.find(".MuiPaper-root")
143143
.withText(
144-
"You require additional permissions in order to view Objects in this bucket. Please ask your MinIO administrator to grant you s3:ListBucket permission in order to view Objects in this bucket."
144+
"You require additional permissions in order to view Objects in this bucket. Please ask your MinIO administrator to grant you"
145145
);
146146
export const createGroupUserTable = Selector(
147147
".MuiDialog-container .ReactVirtualized__Table"

0 commit comments

Comments
 (0)