Skip to content

Commit bd9615e

Browse files
committed
Hide users tab from bucket view when LDAP is enabled
1 parent 8a635fc commit bd9615e

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ const ViewBucket = ({
280280

281281
const bucketName = match.params["bucketName"];
282282
const ilmEnabled = session.features?.indexOf("ilm") > -1;
283-
283+
const usersEnabled = session.pages?.indexOf("/users") > -1;
284+
console.log("usersEnabled", usersEnabled);
284285
// check the permissions for creating bucket
285286
useEffect(() => {
286287
if (loadingPerms) {
@@ -417,7 +418,7 @@ const ViewBucket = ({
417418
}, [loadingPolicy, setErrorSnackMessage, bucketName]);
418419

419420
useEffect(() => {
420-
if (loadingUsers) {
421+
if (loadingUsers && usersEnabled) {
421422
api
422423
.invoke("GET", `/api/v1/bucket-users/${bucketName}`)
423424
.then((res: any) => {
@@ -947,7 +948,7 @@ const ViewBucket = ({
947948
<Tab label="Replication" {...a11yProps(1)} />
948949
)}
949950
<Tab label="Policies" {...a11yProps(2)} />
950-
<Tab label="Users" {...a11yProps(3)} />
951+
{usersEnabled && <Tab label="Users" {...a11yProps(3)} />}
951952
{ilmEnabled && <Tab label="Lifecycle" {...a11yProps(4)} />}
952953
</Tabs>
953954
</Grid>
@@ -1056,15 +1057,18 @@ const ViewBucket = ({
10561057
idField="name"
10571058
/>
10581059
</TabPanel>
1059-
<TabPanel index={3} value={curTab}>
1060-
<TableWrapper
1061-
columns={[{ label: "User", elementKey: "accessKey" }]}
1062-
isLoading={loadingUsers}
1063-
records={bucketUsers}
1064-
entityName="Users"
1065-
idField="accessKey"
1066-
/>
1067-
</TabPanel>
1060+
1061+
{usersEnabled && (
1062+
<TabPanel index={3} value={curTab}>
1063+
<TableWrapper
1064+
columns={[{ label: "User", elementKey: "accessKey" }]}
1065+
isLoading={loadingUsers}
1066+
records={bucketUsers}
1067+
entityName="Users"
1068+
idField="accessKey"
1069+
/>
1070+
</TabPanel>
1071+
)}
10681072
<TabPanel index={4} value={curTab}>
10691073
<TableWrapper
10701074
itemActions={[]}

restapi/error.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ var (
3131
errPolicyNameNotInRequest = errors.New("error policy name not in request")
3232
errPolicyBodyNotInRequest = errors.New("error policy body not in request")
3333
errInvalidEncryptionAlgorithm = errors.New("error invalid encryption algorithm")
34-
errSSENotConfigured = errors.New("error server side encryption configuration was not found")
34+
errSSENotConfigured = errors.New("error server side encryption configuration not found")
35+
errBucketLifeCycleNotConfigured = errors.New("error bucket life cycle configuration not found")
3536
errChangePassword = errors.New("error please check your current password")
3637
errInvalidLicense = errors.New("invalid license key")
3738
errLicenseNotFound = errors.New("license not found")
@@ -99,6 +100,16 @@ func prepareError(err ...error) *models.Error {
99100
errorCode = 401
100101
errorMessage = errorGenericInvalidSession.Error()
101102
}
103+
// Bucket life cycle not configured
104+
if errors.Is(err[0], errBucketLifeCycleNotConfigured) {
105+
errorCode = 404
106+
errorMessage = errBucketLifeCycleNotConfigured.Error()
107+
}
108+
// Encryption not configured
109+
if errors.Is(err[0], errSSENotConfigured) {
110+
errorCode = 404
111+
errorMessage = errSSENotConfigured.Error()
112+
}
102113
// account change password
103114
if madmin.ToErrorResponse(err[0]).Code == "SignatureDoesNotMatch" {
104115
errorCode = 403

restapi/user_buckets_lifecycle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func getBucketLifecycleResponse(session *models.Principal, params user_api.GetBu
106106

107107
bucketEvents, err := getBucketLifecycle(ctx, minioClient, params.BucketName)
108108
if err != nil {
109-
return nil, prepareError(err)
109+
return nil, prepareError(errBucketLifeCycleNotConfigured, err)
110110
}
111111
return bucketEvents, nil
112112
}

0 commit comments

Comments
 (0)