feat(authorization): add Cedar authorization recipe - #591
Open
Jeadie wants to merge 2 commits into
Open
Conversation
Add a self-contained recipe that secures datasets with Cedar authorization policies and OIDC/JWT identity. It shows four distinct patterns from one Spicepod: - Multi-tenancy: tenant_id = current_org_id() - Row-level security: owner = current_user_id(), with an admin override - PII masking: @mask_email / @mask_ssn, conditioned on role - RBAC: role-gated dataset with deny-by-default Identity comes from a small static file server (serve-jwks.py, standard library) that serves an OIDC discovery document and a public JWKS. Four demo tokens are pre-signed and committed, so the recipe runs with no setup. The demo signing key is generated on demand and gitignored — it is not needed to run. Requires the Enterprise distribution of Spice.ai for the authorization and OIDC features. Left unregistered from CI, which does not run enterprise recipes.
| } else { | ||
| const { privateKey } = crypto.generateKeyPairSync("rsa", { modulusLength: 2048 }); | ||
| privateKeyPem = privateKey.export({ type: "pkcs8", format: "pem" }); | ||
| fs.writeFileSync(keyPath, privateKeyPem); |
The admin override now grants a tenant-filtered read (tenant_id = current_org_id()) instead of an unfiltered one, so an admin sees every deal in their own org but not another tenant's. Update the README output and description to match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new self-contained recipe,
authorization/, that secures datasets with Cedar authorization policies and OIDC/JWT identity. It shows four distinct access-control patterns from a single Spicepod:tenant_id = current_org_id()customersowner = current_user_id()deals; anadminsees all@mask_email/@mask_ssn, by rolehrrole may readsalariesMulti-tenancy isolates by organization; RLS isolates by user — a finer grain the tenant filter alone cannot express. The
adminrole is exempt from the ownership filter and granted an unfiltered read, so a manager sees every deal.Identity
To keep the recipe self-contained, the identity provider is a small static file server (
serve-jwks.py, standard library only) that serves an OIDC discovery document and a public JWKS. Four demo tokens are pre-signed and committed, so the recipe runs with no setup. In production you pointissuer_urlat your real identity provider and change nothing else.The demo signing key is not committed — it is generated on demand by
generate-tokens.jsand gitignored. It is not needed to run: Spice validates the pre-signed tokens against the committed public JWKS.Notes
spice-qa.ymlmatrix.acme/globex,exampleemails, placeholder SSNs).Test
Verified end-to-end against an enterprise
spiced: each README command was run and its output matches the committed expected output — tenant isolation, per-user RLS with the admin override, role-conditional masking, and deny-by-default RBAC all behave as documented.