mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
simplify validating policy mapping (#21450)
This commit is contained in:
@@ -545,6 +545,14 @@ func (sts *stsAPIHandlers) AssumeRoleWithSSO(w http.ResponseWriter, r *http.Requ
|
||||
writeSTSErrorResponse(ctx, w, ErrSTSAccessDenied, err)
|
||||
return
|
||||
}
|
||||
if newGlobalAuthZPluginFn() == nil {
|
||||
// if authZ is not set - we expect the policies to be present.
|
||||
if globalIAMSys.CurrentPolicies(p) == "" {
|
||||
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue,
|
||||
fmt.Errorf("None of the given policies (`%s`) are defined, credentials will not be generated", p))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !globalIAMSys.doesPolicyAllow(p, policy.Args{
|
||||
@@ -1003,6 +1011,20 @@ func (sts *stsAPIHandlers) AssumeRoleWithCustomToken(w http.ResponseWriter, r *h
|
||||
return
|
||||
}
|
||||
|
||||
_, policyName, err := globalIAMSys.GetRolePolicy(roleArnStr)
|
||||
if err != nil {
|
||||
writeSTSErrorResponse(ctx, w, ErrSTSAccessDenied, err)
|
||||
return
|
||||
}
|
||||
|
||||
if newGlobalAuthZPluginFn() == nil { // if authZ is not set - we expect the policyname to be present.
|
||||
if globalIAMSys.CurrentPolicies(policyName) == "" {
|
||||
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue,
|
||||
fmt.Errorf("None of the given policies (`%s`) are defined, credentials will not be generated", policyName))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
res, err := authn.Authenticate(roleArn, token)
|
||||
if err != nil {
|
||||
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, err)
|
||||
|
||||
Reference in New Issue
Block a user