Skip to content

Commit a878440

Browse files
authored
Added permissions guidance on ListBuckets and AddBuckets screens (#2319)
Added helpbox and tooltip guidance on ListBucketsand AddBuckets screens Added bucketname to resource checking for bucket level config permissions
1 parent cd6e61e commit a878440

File tree

3 files changed

+119
-45
lines changed

3 files changed

+119
-45
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { selFeatures } from "../../consoleSlice";
4646
import AutoColorIcon from "../../Common/Components/AutoColorIcon";
4747
import TooltipWrapper from "../../Common/TooltipWrapper/TooltipWrapper";
4848
import { Button } from "mds";
49+
import hasPermission from "../../../../common/SecureComponent/accessControl";
4950

5051
const styles = (theme: Theme) =>
5152
createStyles({
@@ -88,6 +89,29 @@ const BrowserHandler = () => {
8889
navigate(`/buckets/${bucketName}/admin`);
8990
};
9091

92+
const configureBucketAllowed = hasPermission(bucketName, [
93+
IAM_SCOPES.S3_GET_BUCKET_POLICY,
94+
IAM_SCOPES.S3_PUT_BUCKET_POLICY,
95+
IAM_SCOPES.S3_GET_BUCKET_VERSIONING,
96+
IAM_SCOPES.S3_PUT_BUCKET_VERSIONING,
97+
IAM_SCOPES.S3_GET_BUCKET_ENCRYPTION_CONFIGURATION,
98+
IAM_SCOPES.S3_PUT_BUCKET_ENCRYPTION_CONFIGURATION,
99+
IAM_SCOPES.S3_DELETE_BUCKET,
100+
IAM_SCOPES.S3_GET_BUCKET_NOTIFICATIONS,
101+
IAM_SCOPES.S3_PUT_BUCKET_NOTIFICATIONS,
102+
IAM_SCOPES.S3_GET_REPLICATION_CONFIGURATION,
103+
IAM_SCOPES.S3_PUT_REPLICATION_CONFIGURATION,
104+
IAM_SCOPES.S3_GET_LIFECYCLE_CONFIGURATION,
105+
IAM_SCOPES.S3_PUT_LIFECYCLE_CONFIGURATION,
106+
IAM_SCOPES.ADMIN_GET_BUCKET_QUOTA,
107+
IAM_SCOPES.ADMIN_SET_BUCKET_QUOTA,
108+
IAM_SCOPES.S3_PUT_BUCKET_TAGGING,
109+
IAM_SCOPES.S3_GET_BUCKET_TAGGING,
110+
IAM_SCOPES.S3_LIST_BUCKET_VERSIONS,
111+
IAM_SCOPES.S3_GET_BUCKET_POLICY_STATUS,
112+
IAM_SCOPES.S3_DELETE_BUCKET_POLICY,
113+
]);
114+
91115
const searchBar = (
92116
<Fragment>
93117
{!versionsMode ? (
@@ -129,7 +153,15 @@ const BrowserHandler = () => {
129153
resource={bucketName}
130154
errorProps={{ disabled: true }}
131155
>
132-
<TooltipWrapper tooltip={"Configure Bucket"}>
156+
<TooltipWrapper
157+
tooltip={
158+
configureBucketAllowed
159+
? "Configure Bucket"
160+
: "You do not have the required permissions to configure this bucket. Please contact your MinIO administrator to request " +
161+
IAM_ROLES.BUCKET_ADMIN +
162+
" permisions."
163+
}
164+
>
133165
<Button
134166
id={"configure-bucket-main"}
135167
color="primary"

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

Lines changed: 69 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import PageLayout from "../../../Common/Layout/PageLayout";
4040
import InputUnitMenu from "../../../Common/FormComponents/InputUnitMenu/InputUnitMenu";
4141
import FormLayout from "../../../Common/FormLayout";
4242
import HelpBox from "../../../../../common/HelpBox";
43+
import TooltipWrapper from "../../../Common/TooltipWrapper/TooltipWrapper";
4344
import SectionTitle from "../../../Common/SectionTitle";
4445
import { selDistSet, selSiteRep } from "../../../../../systemSlice";
4546
import {
@@ -162,9 +163,17 @@ const AddBucket = ({ classes }: IsetProps) => {
162163
(state: AppState) => state.addBucket.navigateTo
163164
);
164165

165-
const lockingAllowed = hasPermission("*", [
166+
const lockingAllowed = hasPermission(
167+
"*",
168+
[
169+
IAM_SCOPES.S3_PUT_BUCKET_VERSIONING,
170+
IAM_SCOPES.S3_PUT_BUCKET_OBJECT_LOCK_CONFIGURATION,
171+
],
172+
true
173+
);
174+
175+
const versioningAllowed = hasPermission("*", [
166176
IAM_SCOPES.S3_PUT_BUCKET_VERSIONING,
167-
IAM_SCOPES.S3_PUT_BUCKET_OBJECT_LOCK_CONFIGURATION,
168177
]);
169178

170179
useEffect(() => {
@@ -243,19 +252,7 @@ const AddBucket = ({ classes }: IsetProps) => {
243252
<br />
244253
<b>Object Locking</b> prevents objects from being deleted.
245254
Required to support retention and legal hold. Can only be
246-
enabled at bucket creation.{" "}
247-
{!lockingAllowed ? (
248-
<Fragment>
249-
<br />
250-
<span>
251-
To enable this option{" "}
252-
<i>s3:PutBucketObjectLockConfiguration</i> and{" "}
253-
<i>s3:PutBucketVersioning</i> permissions must be set.
254-
</span>
255-
</Fragment>
256-
) : (
257-
""
258-
)}
255+
enabled at bucket creation.
259256
<br />
260257
<br />
261258
<b>Quota</b> limits the amount of data in the bucket.
@@ -323,39 +320,68 @@ const AddBucket = ({ classes }: IsetProps) => {
323320
<br />
324321
</Fragment>
325322
)}
326-
<FormSwitchWrapper
327-
value="versioned"
328-
id="versioned"
329-
name="versioned"
330-
checked={versioningEnabled}
331-
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
332-
dispatch(setVersioning(event.target.checked));
333-
}}
334-
label={"Versioning"}
335-
disabled={
336-
!distributedSetup ||
337-
lockingEnabled ||
338-
siteReplicationInfo.enabled
323+
<TooltipWrapper
324+
tooltip={
325+
versioningAllowed
326+
? ""
327+
: "You require additional permissions in order to enable Versioning. Please ask your MinIO administrator to grant you " +
328+
IAM_SCOPES.S3_PUT_BUCKET_VERSIONING +
329+
" permission in order to enable Versioning."
339330
}
340-
/>
331+
>
332+
<FormSwitchWrapper
333+
value="versioned"
334+
id="versioned"
335+
name="versioned"
336+
checked={versioningEnabled}
337+
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
338+
dispatch(setVersioning(event.target.checked));
339+
}}
340+
label={"Versioning"}
341+
disabled={
342+
!distributedSetup ||
343+
lockingEnabled ||
344+
siteReplicationInfo.enabled ||
345+
!versioningAllowed
346+
}
347+
/>
348+
</TooltipWrapper>
341349
</Grid>
342350
<Grid item xs={12}>
343-
<FormSwitchWrapper
344-
value="locking"
345-
id="locking"
346-
name="locking"
347-
disabled={
348-
lockingFieldDisabled || !distributedSetup || !lockingAllowed
351+
<TooltipWrapper
352+
tooltip={
353+
lockingAllowed
354+
? ""
355+
: "You require additional permissions in order to enable Locking. Please ask your MinIO administrator to grant you " +
356+
(versioningAllowed
357+
? ""
358+
: IAM_SCOPES.S3_PUT_BUCKET_VERSIONING + " and ") +
359+
IAM_SCOPES.S3_PUT_BUCKET_OBJECT_LOCK_CONFIGURATION +
360+
" permissions in order to enable Locking."
349361
}
350-
checked={lockingEnabled}
351-
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
352-
dispatch(setEnableObjectLocking(event.target.checked));
353-
if (event.target.checked && !siteReplicationInfo.enabled) {
354-
dispatch(setVersioning(true));
362+
>
363+
<FormSwitchWrapper
364+
value="locking"
365+
id="locking"
366+
name="locking"
367+
disabled={
368+
lockingFieldDisabled ||
369+
!distributedSetup ||
370+
!lockingAllowed
355371
}
356-
}}
357-
label={"Object Locking"}
358-
/>
372+
checked={lockingEnabled}
373+
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
374+
dispatch(setEnableObjectLocking(event.target.checked));
375+
if (
376+
event.target.checked &&
377+
!siteReplicationInfo.enabled
378+
) {
379+
dispatch(setVersioning(true));
380+
}
381+
}}
382+
label={"Object Locking"}
383+
/>
384+
</TooltipWrapper>
359385
</Grid>
360386

361387
<Grid item xs={12}>

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ const ListBuckets = ({ classes }: IListBucketsProps) => {
202202
};
203203

204204
const canCreateBucket = hasPermission("*", [IAM_SCOPES.S3_CREATE_BUCKET]);
205+
const canListBuckets = hasPermission("*", [IAM_SCOPES.S3_LIST_BUCKET]);
205206

206207
return (
207208
<Fragment>
@@ -319,7 +320,15 @@ const ListBuckets = ({ classes }: IListBucketsProps) => {
319320
</TooltipWrapper>
320321

321322
{!obOnly && (
322-
<TooltipWrapper tooltip={"Create Bucket"}>
323+
<TooltipWrapper
324+
tooltip={
325+
canCreateBucket
326+
? "Create Bucket"
327+
: "You require additional permissions in order to create a new Bucket. Please ask your MinIO administrator to grant you " +
328+
IAM_SCOPES.S3_CREATE_BUCKET +
329+
" permission in order to create a Bucket."
330+
}
331+
>
323332
<Button
324333
id={"create-bucket"}
325334
onClick={() => {
@@ -384,6 +393,13 @@ const ListBuckets = ({ classes }: IListBucketsProps) => {
384393
MinIO uses buckets to organize objects. A bucket is
385394
similar to a folder or directory in a filesystem, where
386395
each bucket can hold an arbitrary number of objects.
396+
<br></br>
397+
<br></br>
398+
{canListBuckets
399+
? ""
400+
: "In order to view the buckets on this server, you require " +
401+
IAM_SCOPES.S3_LIST_BUCKET +
402+
" permission. Please contact your MinIO administrator to establish this permission."}
387403
<SecureComponent
388404
scopes={[IAM_SCOPES.S3_CREATE_BUCKET]}
389405
resource={CONSOLE_UI_RESOURCE}

0 commit comments

Comments
 (0)