Skip to content

Commit 7dea640

Browse files
fix(authz): Return deny on GetDecision if resource attribute lookup returns not found (#962)
resolves #950
1 parent b026fda commit 7dea640

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

service/authorization/authorization.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,28 @@ func (as *AuthorizationService) GetDecisions(ctx context.Context, req *authoriza
166166
// get attribute definition/value combinations
167167
dataAttrDefsAndVals, err := retrieveAttributeDefinitions(ctx, ra, as.sdk)
168168
if err != nil {
169-
// TODO: should all decisions in a request fail if one FQN lookup fails?
169+
// if attribute an FQN does not exist
170+
// return deny for all entity chains aginst this RA set and continue to next
171+
if errors.Is(err, db.StatusifyError(db.ErrNotFound, "")) {
172+
for _, ec := range dr.GetEntityChains() {
173+
decisionResp := &authorization.DecisionResponse{
174+
Decision: authorization.DecisionResponse_DECISION_DENY,
175+
EntityChainId: ec.GetId(),
176+
Action: &policy.Action{
177+
Value: &policy.Action_Standard{
178+
Standard: policy.Action_STANDARD_ACTION_TRANSMIT,
179+
},
180+
},
181+
}
182+
if ra.GetResourceAttributesId() != "" {
183+
decisionResp.ResourceAttributesId = ra.GetResourceAttributesId()
184+
} else if len(ra.GetAttributeValueFqns()) > 0 {
185+
decisionResp.ResourceAttributesId = ra.GetAttributeValueFqns()[0]
186+
}
187+
rsp.DecisionResponses = append(rsp.DecisionResponses, decisionResp)
188+
}
189+
continue
190+
}
170191
return nil, db.StatusifyError(err, db.ErrTextGetRetrievalFailed, slog.String("fqns", strings.Join(ra.GetAttributeValueFqns(), ", ")))
171192
}
172193
var attrDefs []*policy.Attribute

0 commit comments

Comments
 (0)