mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
Add default canned policies (#6690)
This commit is contained in:
committed by
kannappanr
parent
e6252dee5a
commit
fde8c38638
19
cmd/iam.go
19
cmd/iam.go
@@ -632,6 +632,22 @@ func reloadUsers(objectAPI ObjectLayer, prefix string, usersMap map[string]auth.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Set default canned policies only if not already overridden by users.
|
||||
func setDefaultCannedPolicies(policies map[string]iampolicy.Policy) {
|
||||
_, ok := policies["writeonly"]
|
||||
if !ok {
|
||||
policies["writeonly"] = iampolicy.WriteOnly
|
||||
}
|
||||
_, ok = policies["readonly"]
|
||||
if !ok {
|
||||
policies["readonly"] = iampolicy.ReadOnly
|
||||
}
|
||||
_, ok = policies["readwrite"]
|
||||
if !ok {
|
||||
policies["readwrite"] = iampolicy.ReadWrite
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh IAMSys.
|
||||
func (sys *IAMSys) refresh(objAPI ObjectLayer) error {
|
||||
iamUsersMap := make(map[string]auth.Credentials)
|
||||
@@ -660,6 +676,9 @@ func (sys *IAMSys) refresh(objAPI ObjectLayer) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Sets default canned policies, if none set.
|
||||
setDefaultCannedPolicies(iamCannedPolicyMap)
|
||||
|
||||
sys.Lock()
|
||||
defer sys.Unlock()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user