mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
cleanup handling of STS isAllowed and simplifies the PolicyDBGet() (#18554)
This commit is contained in:
@@ -655,7 +655,7 @@ func (store *IAMStoreSys) GroupNotificationHandler(ctx context.Context, group st
|
||||
|
||||
// PolicyDBGet - fetches policies associated with the given user or group, and
|
||||
// additional groups if provided.
|
||||
func (store *IAMStoreSys) PolicyDBGet(name string, isGroup bool, groups ...string) ([]string, error) {
|
||||
func (store *IAMStoreSys) PolicyDBGet(name string, groups ...string) ([]string, error) {
|
||||
if name == "" {
|
||||
return nil, errInvalidArgument
|
||||
}
|
||||
@@ -663,19 +663,17 @@ func (store *IAMStoreSys) PolicyDBGet(name string, isGroup bool, groups ...strin
|
||||
cache := store.rlock()
|
||||
defer store.runlock()
|
||||
|
||||
policies, _, err := cache.policyDBGet(store, name, isGroup)
|
||||
policies, _, err := cache.policyDBGet(store, name, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !isGroup {
|
||||
for _, group := range groups {
|
||||
ps, _, err := cache.policyDBGet(store, group, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
policies = append(policies, ps...)
|
||||
for _, group := range groups {
|
||||
ps, _, err := cache.policyDBGet(store, group, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
policies = append(policies, ps...)
|
||||
}
|
||||
|
||||
return policies, nil
|
||||
@@ -1219,6 +1217,9 @@ func (store *IAMStoreSys) GetPolicy(name string) (policy.Policy, error) {
|
||||
}
|
||||
toMerge = append(toMerge, v.Policy)
|
||||
}
|
||||
if len(toMerge) == 0 {
|
||||
return policy.Policy{}, errNoSuchPolicy
|
||||
}
|
||||
return policy.MergePolicies(toMerge...), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user