Skip to content

Commit e869b35

Browse files
authored
fix(authz): if entity identifier results in multiple representations, treat with AND in resource decision results (#2860)
### Proposed Changes * Make sure an entity identifier that breaks out into multiple entity representations when back from the ERS response results in AND logic across the representations on each individual resource * Audit should log for each entity representation for clarity (possible to provide an entity chain with dozens of email addresses in a single identifier, so there should be a log to audit for each representation of an entity from the chained email address entities) ### Checklist - [ ] I have added or updated unit tests - [ ] I have added or updated integration tests (if appropriate) - [ ] I have added or updated documentation ### Testing Instructions
1 parent 32a7e91 commit e869b35

File tree

11 files changed

+714
-774
lines changed

11 files changed

+714
-774
lines changed

.github/workflows/checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ jobs:
214214
mkcert -cert-file ./keys/platform.crt -key-file ./keys/platform-key.pem localhost
215215
cp opentdf-dev.yaml opentdf.yaml
216216
yq eval '.server.tls.enabled = true' -i opentdf.yaml
217-
yq eval '.trace = {"enabled":true}' -i opentdf.yaml
217+
yq eval '.server.trace.enabled = true' -i opentdf.yaml
218218
- name: Added Trusted Certs
219219
run: |
220220
sudo chmod -R 777 ./keys

service/authorization/v2/authorization.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (as *Service) GetDecision(ctx context.Context, req *connect.Request[authzV2
188188
return nil, statusifyError(ctx, as.logger, err)
189189
}
190190

191-
decisions, permitted, err := pdp.GetDecision(
191+
decision, err := pdp.GetDecision(
192192
ctx,
193193
entityIdentifier,
194194
action,
@@ -199,10 +199,15 @@ func (as *Service) GetDecision(ctx context.Context, req *connect.Request[authzV2
199199
if err != nil {
200200
return nil, statusifyError(ctx, as.logger, err)
201201
}
202-
resp, err := rollupSingleResourceDecision(permitted, decisions)
202+
203+
resourceDecisions, err := rollupResourceDecisions(decision)
203204
if err != nil {
204205
return nil, statusifyError(ctx, as.logger, err)
205206
}
207+
208+
resp := &authzV2.GetDecisionResponse{
209+
Decision: resourceDecisions[0],
210+
}
206211
return connect.NewResponse(resp), nil
207212
}
208213

@@ -232,7 +237,7 @@ func (as *Service) GetDecisionMultiResource(ctx context.Context, req *connect.Re
232237
return nil, statusifyError(ctx, as.logger, err)
233238
}
234239

235-
decisions, allPermitted, err := pdp.GetDecision(
240+
decision, err := pdp.GetDecision(
236241
ctx,
237242
entityIdentifier,
238243
action,
@@ -244,14 +249,14 @@ func (as *Service) GetDecisionMultiResource(ctx context.Context, req *connect.Re
244249
return nil, statusifyError(ctx, as.logger, errors.Join(ErrFailedToGetDecision, err))
245250
}
246251

247-
resourceDecisions, err := rollupMultiResourceDecisions(decisions)
252+
resourceDecisions, err := rollupResourceDecisions(decision)
248253
if err != nil {
249254
return nil, statusifyError(ctx, as.logger, err)
250255
}
251256

252257
resp := &authzV2.GetDecisionMultiResourceResponse{
253258
AllPermitted: &wrapperspb.BoolValue{
254-
Value: allPermitted,
259+
Value: decision.AllPermitted,
255260
},
256261
ResourceDecisions: resourceDecisions,
257262
}
@@ -291,19 +296,19 @@ func (as *Service) GetDecisionBulk(ctx context.Context, req *connect.Request[aut
291296
resources := request.GetResources()
292297
fulfillableObligations := request.GetFulfillableObligationFqns()
293298

294-
decisions, allPermitted, err := pdp.GetDecision(ctx, entityIdentifier, action, resources, reqContext, fulfillableObligations)
299+
decision, err := pdp.GetDecision(ctx, entityIdentifier, action, resources, reqContext, fulfillableObligations)
295300
if err != nil {
296301
return nil, statusifyError(ctx, as.logger, errors.Join(ErrFailedToGetDecision, err))
297302
}
298303

299-
resourceDecisions, err := rollupMultiResourceDecisions(decisions)
304+
resourceDecisions, err := rollupResourceDecisions(decision)
300305
if err != nil {
301306
return nil, statusifyError(ctx, as.logger, err, slog.Int("index", idx))
302307
}
303308

304309
decisionResponse := &authzV2.GetDecisionMultiResourceResponse{
305310
AllPermitted: &wrapperspb.BoolValue{
306-
Value: allPermitted,
311+
Value: decision.AllPermitted,
307312
},
308313
ResourceDecisions: resourceDecisions,
309314
}

0 commit comments

Comments
 (0)