@ -1288,14 +1288,14 @@ func (sys *IAMSys) IsAllowedSTS(args iampolicy.Args) bool {
return combinedPolicy . IsAllowed ( args )
return combinedPolicy . IsAllowed ( args )
}
}
pname , ok := args . Claims [ iamPolicyName ( ) ]
pnameSlice , ok := args . GetPolicies ( iamPolicyClaimName ( ) )
if ! ok {
if ! ok {
// When claims are set, it should have a "policy" field.
// When claims are set, it should have a policy claim field.
return false
return false
}
}
pnameStr , ok := pname . ( string )
if ! ok {
// When claims are set, it should have a policy claim field.
// When claims has "policy" field, it should be string.
if len ( pnameSlice ) == 0 {
return false
return false
}
}
@ -1310,7 +1310,7 @@ func (sys *IAMSys) IsAllowedSTS(args iampolicy.Args) bool {
}
}
name := mp . Policy
name := mp . Policy
if pnameStr != name {
if pnameSlice [ 0 ] != name {
// When claims has a policy, it should match the
// When claims has a policy, it should match the
// policy of args.AccountName which server remembers.
// policy of args.AccountName which server remembers.
// if not reject such requests.
// if not reject such requests.
@ -1319,36 +1319,36 @@ func (sys *IAMSys) IsAllowedSTS(args iampolicy.Args) bool {
// Now check if we have a sessionPolicy.
// Now check if we have a sessionPolicy.
spolicy , ok := args . Claims [ iampolicy . SessionPolicyName ]
spolicy , ok := args . Claims [ iampolicy . SessionPolicyName ]
if ! ok {
if ok {
// Sub policy not set, this is most common since subPolicy
spolicyStr , ok := spolicy . ( string )
// is optional, use the top level policy only.
if ! ok {
p , ok := sys . iamPolicyDocsMap [ pnameStr ]
// Sub policy if set, should be a string reject
return ok && p . IsAllowed ( args )
// malformed/malicious requests.
}
return false
}
spolicyStr , ok := spolicy . ( string )
// Check if policy is parseable.
if ! ok {
subPolicy , err := iampolicy . ParseConfig ( bytes . NewReader ( [ ] byte ( spolicyStr ) ) )
// Sub policy if set, should be a string reject
if err != nil {
// malformed/malicious requests.
// Log any error in input session policy config.
return false
logger . LogIf ( context . Background ( ) , err )
}
return false
}
// Check if policy is parseable.
// Policy without Version string value reject it.
subPolicy , err := iampolicy . ParseConfig ( bytes . NewReader ( [ ] byte ( spolicyStr ) ) )
if subPolicy . Version == "" {
if err != nil {
return false
// Log any error in input session policy config.
}
logger . LogIf ( context . Background ( ) , err )
return false
}
// Policy without Version string value reject it .
// Sub policy is set and valid.
if subPolicy . Version == "" {
p , ok := sys . iamPolicyDocsMap [ pnameSlice [ 0 ] ]
return fals e
return ok && p . IsAllowed ( args ) && subPolicy . IsAllow ed ( args )
}
}
// Sub policy is set and valid.
// Sub policy not set, this is most common since subPolicy
p , ok := sys . iamPolicyDocsMap [ pnameStr ]
// is optional, use the top level policy only.
return ok && p . IsAllowed ( args ) && subPolicy . IsAllowed ( args )
p , ok := sys . iamPolicyDocsMap [ pnameSlice [ 0 ] ]
return ok && p . IsAllowed ( args )
}
}
// IsAllowed - checks given policy args is allowed to continue the Rest API.
// IsAllowed - checks given policy args is allowed to continue the Rest API.