Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions pkg/acl/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,8 @@ var serviceAccountsActionSet = ConfigurationActionSet{

// changePasswordActionSet requires admin:CreateUser policy permission
var changePasswordActionSet = ConfigurationActionSet{
actionTypes: iampolicy.NewActionSet(
iampolicy.AllAdminActions,
),
actions: iampolicy.NewActionSet(
iampolicy.CreateUserAdminAction,
),
actionTypes: iampolicy.NewActionSet(),
actions: iampolicy.NewActionSet(),
}

// tenantsActionSet temporally no actions needed for tenants sections to work
Expand Down
10 changes: 5 additions & 5 deletions pkg/acl/endpoints_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is part of MinIO Orchestrator
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -50,7 +50,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) {
args: args{
[]string{"admin:ServerInfo"},
},
want: 6,
want: 7,
},
{
name: "policies endpoint",
Expand All @@ -63,7 +63,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) {
"admin:ListUserPolicies",
},
},
want: 7,
want: 8,
},
{
name: "all admin endpoints",
Expand All @@ -81,7 +81,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) {
"s3:*",
},
},
want: 14,
want: 15,
},
{
name: "all admin and s3 endpoints",
Expand All @@ -98,7 +98,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) {
args: args{
[]string{},
},
want: 5,
want: 6,
},
}

Expand Down
8 changes: 5 additions & 3 deletions restapi/user_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ func getUserHasPermissionsResponse(session *models.Principal, params user_api.Ha

for _, p := range params.Body.Actions {
canPerform := userCanDo(iampolicy.Args{
Action: iampolicy.Action(p.Action),
BucketName: p.BucketName,
Action: iampolicy.Action(p.Action),
}, userPolicy)
perms = append(perms, &models.PermissionAction{
Can: canPerform,
Expand All @@ -140,7 +139,10 @@ func getUserHasPermissionsResponse(session *models.Principal, params user_api.Ha
func userCanDo(arg iampolicy.Args, userPolicy *iampolicy.Policy) bool {
// check in all the statements if any allows the passed action
for _, stmt := range userPolicy.Statements {
if stmt.IsAllowed(arg) {
// We only care about actions to match -
// if resources match or not we do not
// care since those are dynamic entities.
if stmt.Actions.Match(arg.Action) {
return true
}
}
Expand Down
4 changes: 2 additions & 2 deletions restapi/user_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func Test_useCanDo(t *testing.T) {
]
}`,
},
want: false,
want: true,
},
{
name: "Create Bucket, With Bucket Name",
Expand All @@ -217,7 +217,7 @@ func Test_useCanDo(t *testing.T) {
]
}`,
},
want: false,
want: true,
},
{
name: "Can't Create Bucket",
Expand Down