Skip to content

Commit b322ff7

Browse files
Jillian InapurapuJillian Inapurapu
authored andcommitted
Merge branch 'deny_checking' into listbuckets_tooltip_fix
2 parents 47f6db3 + dc1c67c commit b322ff7

File tree

8 files changed

+18
-39
lines changed

8 files changed

+18
-39
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,12 @@ const hasPermission = (
6363
}
6464
return null;
6565
});
66+
6667
return items.filter((itm) => itm !== null);
6768
};
68-
6969
resources.forEach((rsItem) => {
7070
// Validation against inner paths & wildcards
7171
let wildcardRules = getMatchingWildcards(rsItem);
72-
7372
let wildcardGrants: string[] = [];
7473

7574
wildcardRules.forEach((rule) => {
@@ -78,7 +77,6 @@ const hasPermission = (
7877
wildcardGrants = [...wildcardGrants, ...wcResources];
7978
}
8079
});
81-
8280
let simpleResources = get(sessionGrants, rsItem, []);
8381
simpleResources = simpleResources || [];
8482
const s3Resources = get(sessionGrants, `arn:aws:s3:::${rsItem}/*`, []);
@@ -119,7 +117,6 @@ const hasPermission = (
119117
});
120118
});
121119
}
122-
123120
return hasAccessToResource(
124121
[
125122
...resourceGrants,

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const IAM_SCOPES = {
2727
S3_GET_BUCKET_POLICY: "s3:GetBucketPolicy",
2828
S3_PUT_BUCKET_POLICY: "s3:PutBucketPolicy",
2929
S3_GET_OBJECT: "s3:GetObject",
30-
S3_STAR_OBJECT: "s3:*Object",
30+
//S3_STAR_OBJECT: "s3:*Object",
3131
S3_PUT_OBJECT: "s3:PutObject",
3232
S3_GET_OBJECT_LEGAL_HOLD: "s3:GetObjectLegalHold",
3333
S3_PUT_OBJECT_LEGAL_HOLD: "s3:PutObjectLegalHold",
@@ -282,7 +282,6 @@ export const IAM_PERMISSIONS = {
282282
IAM_SCOPES.ADMIN_LIST_USER_POLICIES,
283283
IAM_SCOPES.ADMIN_LIST_USERS,
284284
IAM_SCOPES.ADMIN_HEAL,
285-
IAM_SCOPES.S3_STAR_BUCKET,
286285
],
287286
[IAM_ROLES.BUCKET_LIFECYCLE]: [
288287
IAM_SCOPES.S3_GET_LIFECYCLE_CONFIGURATION,
@@ -532,10 +531,6 @@ export const listGroupPermissions = [
532531
export const deleteBucketPermissions = [
533532
IAM_SCOPES.S3_DELETE_BUCKET,
534533
IAM_SCOPES.S3_FORCE_DELETE_BUCKET,
535-
IAM_SCOPES.S3_STAR_BUCKET,
536534
];
537535

538-
export const browseBucketPermissions = [
539-
IAM_SCOPES.S3_LIST_BUCKET,
540-
IAM_SCOPES.S3_STAR_BUCKET,
541-
];
536+
export const browseBucketPermissions = [IAM_SCOPES.S3_LIST_BUCKET];

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ const BrowserHandler = () => {
110110
IAM_SCOPES.S3_LIST_BUCKET_VERSIONS,
111111
IAM_SCOPES.S3_GET_BUCKET_POLICY_STATUS,
112112
IAM_SCOPES.S3_DELETE_BUCKET_POLICY,
113-
IAM_SCOPES.S3_STAR_BUCKET,
114113
]);
115114

116115
const searchBar = (

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,7 @@ const ListBuckets = ({ classes }: IListBucketsProps) => {
217217
setSelectedBuckets(selectAllBuckets);
218218
};
219219

220-
const canCreateBucket = hasPermission("*", [
221-
IAM_SCOPES.S3_CREATE_BUCKET,
222-
IAM_SCOPES.S3_STAR_BUCKET,
223-
]);
220+
const canCreateBucket = hasPermission("*", [IAM_SCOPES.S3_CREATE_BUCKET]);
224221
const canListBuckets = hasPermission("*", [IAM_SCOPES.S3_LIST_BUCKET]);
225222

226223
return (
@@ -461,10 +458,7 @@ const ListBuckets = ({ classes }: IListBucketsProps) => {
461458
</Fragment>
462459
)}
463460
<SecureComponent
464-
scopes={[
465-
IAM_SCOPES.S3_CREATE_BUCKET,
466-
IAM_SCOPES.S3_STAR_BUCKET,
467-
]}
461+
scopes={[IAM_SCOPES.S3_CREATE_BUCKET]}
468462
resource={CONSOLE_UI_RESOURCE}
469463
>
470464
<br />

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,18 +1236,9 @@ const ListObjects = () => {
12361236
uploadPath = uploadPath.concat(currentPath);
12371237
}
12381238

1239-
const canDownload = hasPermission(bucketName, [
1240-
IAM_SCOPES.S3_GET_OBJECT,
1241-
IAM_SCOPES.S3_STAR_OBJECT,
1242-
]);
1243-
const canDelete = hasPermission(bucketName, [
1244-
IAM_SCOPES.S3_DELETE_OBJECT,
1245-
IAM_SCOPES.S3_STAR_OBJECT,
1246-
]);
1247-
const canUpload = hasPermission(uploadPath, [
1248-
IAM_SCOPES.S3_PUT_OBJECT,
1249-
IAM_SCOPES.S3_STAR_OBJECT,
1250-
]);
1239+
const canDownload = hasPermission(bucketName, [IAM_SCOPES.S3_GET_OBJECT]);
1240+
const canDelete = hasPermission(bucketName, [IAM_SCOPES.S3_DELETE_OBJECT]);
1241+
const canUpload = hasPermission(uploadPath, [IAM_SCOPES.S3_PUT_OBJECT]);
12511242

12521243
const onClosePanel = (forceRefresh: boolean) => {
12531244
dispatch(setSelectedObjectView(null));

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ const ObjectDetailPanel = ({
430430
]);
431431
const canGetObject = hasPermission(objectResources, [
432432
IAM_SCOPES.S3_GET_OBJECT,
433-
IAM_SCOPES.S3_STAR_OBJECT,
434433
]);
435434
const canDelete = hasPermission(
436435
[bucketName, currentItem, [bucketName, actualInfo.name].join("/")],

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ const UploadFilesButton = ({
6969

7070
const uploadObjectAllowed = hasPermission(uploadPath, [
7171
IAM_SCOPES.S3_PUT_OBJECT,
72-
IAM_SCOPES.S3_STAR_OBJECT,
7372
]);
7473
const uploadFolderAllowed = hasPermission(
7574
bucketName,
76-
[IAM_SCOPES.S3_PUT_OBJECT, IAM_SCOPES.S3_STAR_OBJECT],
75+
[IAM_SCOPES.S3_PUT_OBJECT],
7776
false,
7877
true
7978
);

restapi/user_session.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"context"
2222
"encoding/json"
23+
"fmt"
2324
"strconv"
2425
"time"
2526

@@ -97,12 +98,13 @@ func getSessionResponse(ctx context.Context, session *models.Principal) (*models
9798
}
9899
erasure := accountInfo.Server.Type == madmin.Erasure
99100
rawPolicy := policies.ReplacePolicyVariables(tokenClaims, accountInfo)
101+
100102
policy, err := minioIAMPolicy.ParseConfig(bytes.NewReader(rawPolicy))
101103
if err != nil {
102104
return nil, ErrorWithContext(ctx, err, ErrInvalidSession)
103105
}
104106
currTime := time.Now().UTC()
105-
107+
fmt.Println("policy=========", policy)
106108
customStyles := session.CustomStyleOb
107109
// This actions will be global, meaning has to be attached to all resources
108110
conditionValues := map[string][]string{
@@ -136,14 +138,14 @@ func getSessionResponse(ctx context.Context, session *models.Principal) (*models
136138
// store all claims from sessionToken
137139
conditionValues[k] = []string{vstr}
138140
}
139-
141+
fmt.Println("conditionValues=========", conditionValues)
140142
defaultActions := policy.IsAllowedActions("", "", conditionValues)
141-
143+
fmt.Println("defaultActions=========", defaultActions)
142144
permissions := map[string]minioIAMPolicy.ActionSet{
143145
ConsoleResourceName: defaultActions,
144146
}
145-
deniedActions := map[string]minioIAMPolicy.ActionSet{}
146147

148+
deniedActions := map[string]minioIAMPolicy.ActionSet{}
147149
var allowResources []*models.PermissionResource
148150

149151
for _, statement := range policy.Statements {
@@ -220,6 +222,9 @@ func getSessionResponse(ctx context.Context, session *models.Principal) (*models
220222
}
221223
}
222224
}
225+
fmt.Println("permissions=================", permissions)
226+
227+
fmt.Println("deniedActions================", deniedActions)
223228
resourcePermissions := map[string][]string{}
224229
for key, val := range permissions {
225230
var resourceActions []string

0 commit comments

Comments
 (0)