Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(authz): Return deny on GetDecision if resource attribute lookup returns not found #962

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion service/authorization/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,28 @@ func (as *AuthorizationService) GetDecisions(ctx context.Context, req *authoriza
// get attribute definition/value combinations
dataAttrDefsAndVals, err := retrieveAttributeDefinitions(ctx, ra, as.sdk)
if err != nil {
// TODO: should all decisions in a request fail if one FQN lookup fails?
// if attribute an FQN does not exist
// return deny for all entity chains aginst this RA set and continue to next
if errors.Is(err, db.StatusifyError(db.ErrNotFound, "")) {
for _, ec := range dr.GetEntityChains() {
decisionResp := &authorization.DecisionResponse{
Decision: authorization.DecisionResponse_DECISION_DENY,
EntityChainId: ec.GetId(),
Action: &policy.Action{
Value: &policy.Action_Standard{
Standard: policy.Action_STANDARD_ACTION_TRANSMIT,
},
},
}
if ra.GetResourceAttributesId() != "" {
decisionResp.ResourceAttributesId = ra.GetResourceAttributesId()
} else if len(ra.GetAttributeValueFqns()) > 0 {
decisionResp.ResourceAttributesId = ra.GetAttributeValueFqns()[0]
}
rsp.DecisionResponses = append(rsp.DecisionResponses, decisionResp)
}
continue
}
return nil, db.StatusifyError(err, db.ErrTextGetRetrievalFailed, slog.String("fqns", strings.Join(ra.GetAttributeValueFqns(), ", ")))
}
var attrDefs []*policy.Attribute
Expand Down
Loading