mirror of
https://github.com/minio/minio.git
synced 2025-01-25 21:53:16 -05:00
svc: Display the correct policy of a particular service account (#12064)
For InfoServiceAccount API, calculating the policy before showing it to the user was not correctly done (only UX issue, not a security issue) This commit fixes it.
This commit is contained in:
parent
39dd9b6483
commit
b6f5785a6d
@ -727,14 +727,14 @@ func (a adminAPIHandlers) InfoServiceAccount(w http.ResponseWriter, r *http.Requ
|
|||||||
|
|
||||||
// If policy is empty, check for policy of the parent user
|
// If policy is empty, check for policy of the parent user
|
||||||
if !impliedPolicy {
|
if !impliedPolicy {
|
||||||
svcAccountPolicy.Merge(*policy)
|
svcAccountPolicy = svcAccountPolicy.Merge(*policy)
|
||||||
} else {
|
} else {
|
||||||
policiesNames, err := globalIAMSys.PolicyDBGet(svcAccount.AccessKey, false)
|
policiesNames, err := globalIAMSys.PolicyDBGet(svcAccount.AccessKey, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
svcAccountPolicy.Merge(globalIAMSys.GetCombinedPolicy(policiesNames...))
|
svcAccountPolicy = svcAccountPolicy.Merge(globalIAMSys.GetCombinedPolicy(policiesNames...))
|
||||||
}
|
}
|
||||||
|
|
||||||
policyJSON, err := json.Marshal(svcAccountPolicy)
|
policyJSON, err := json.Marshal(svcAccountPolicy)
|
||||||
|
11
cmd/iam.go
11
cmd/iam.go
@ -1138,7 +1138,7 @@ func (sys *IAMSys) NewServiceAccount(ctx context.Context, parentUser string, gro
|
|||||||
}
|
}
|
||||||
cred.ParentUser = parentUser
|
cred.ParentUser = parentUser
|
||||||
cred.Groups = groups
|
cred.Groups = groups
|
||||||
cred.Status = string(madmin.AccountEnabled)
|
cred.Status = string(auth.AccountOn)
|
||||||
|
|
||||||
u := newUserIdentity(cred)
|
u := newUserIdentity(cred)
|
||||||
|
|
||||||
@ -1257,10 +1257,13 @@ func (sys *IAMSys) GetServiceAccount(ctx context.Context, accessKey string) (aut
|
|||||||
pt, ptok := jwtClaims.Lookup(iamPolicyClaimNameSA())
|
pt, ptok := jwtClaims.Lookup(iamPolicyClaimNameSA())
|
||||||
sp, spok := jwtClaims.Lookup(iampolicy.SessionPolicyName)
|
sp, spok := jwtClaims.Lookup(iampolicy.SessionPolicyName)
|
||||||
if ptok && spok && pt == "embedded-policy" {
|
if ptok && spok && pt == "embedded-policy" {
|
||||||
p, err := iampolicy.ParseConfig(bytes.NewReader([]byte(sp)))
|
policyBytes, err := base64.StdEncoding.DecodeString(sp)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
embeddedPolicy = &iampolicy.Policy{}
|
p, err := iampolicy.ParseConfig(bytes.NewReader(policyBytes))
|
||||||
embeddedPolicy.Merge(*p)
|
if err == nil {
|
||||||
|
policy := iampolicy.Policy{}.Merge(*p)
|
||||||
|
embeddedPolicy = &policy
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user