Skip to content

auth/opa: add WithStore option and fix concurrent print-buffer race#620

Open
sfc-gh-ikryvanos wants to merge 1 commit into
mainfrom
opa-authz-data-injection-and-print-race
Open

auth/opa: add WithStore option and fix concurrent print-buffer race#620
sfc-gh-ikryvanos wants to merge 1 commit into
mainfrom
opa-authz-data-injection-and-print-race

Conversation

@sfc-gh-ikryvanos

Copy link
Copy Markdown
Collaborator

Add a WithStore option to NewOpaAuthzPolicy so a policy can be parameterized through the data document (for example data.config) instead of hard-coding values in the policy file. The supplied store is applied to both the allow query and the denial-hints query.

Also fix a data race: opaAuthzPolicy shared a single bytes.Buffer for rego print output across all evaluations, and that buffer is written concurrently whenever Eval is called from multiple goroutines (the normal case for a gRPC server). Each Eval now uses its own buffer, supplied per call via rego.EvalPrintHook.

Add a WithStore option to NewOpaAuthzPolicy so a policy can be
parameterized through the `data` document (for example data.config)
instead of hard-coding values in the policy file. The supplied store is
applied to both the allow query and the denial-hints query.

Also fix a data race: opaAuthzPolicy shared a single bytes.Buffer for
rego print output across all evaluations, and that buffer is written
concurrently whenever Eval is called from multiple goroutines (the normal
case for a gRPC server). Each Eval now uses its own buffer, supplied per
call via rego.EvalPrintHook.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant