Draft
Conversation
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.
Summary
FilePolicy, a per-volume function(action, resource, user) → boolean | Promise<boolean>that gates every file operation before the Databricks API call is made. Ships with built-in helpers (policy.publicRead(),policy.allowAll(),policy.denyAll()) and combinators (all,any,not) for composition.x-forwarded-userheader and passed to the policy.publicRead(): Volumes without an explicit policy default to read-only access. A startup warning encourages setting an explicit policy.Motivation
Previously the files plugin relied entirely on OBO (on-behalf-of) token forwarding and Unity Catalog grants to restrict access. This meant:
WRITE_VOLUMEgrant had no effect on HTTP routes since the SP's credentials were used anyway.Policies close this gap by giving developers a composable, per-volume authorization layer evaluated before any API call.
Key changes
packages/appkit/src/plugins/files/policy.tsFileAction,FileResource,FilePolicyUsertypes,PolicyDeniedError, and thepolicycombinator namespacepackages/appkit/src/plugins/files/plugin.tsVolumeHandleAPI. RemovedisInUserContextgating in favor of SP-first execution + policy enforcementpackages/appkit/src/plugins/files/types.tspolicy?: FilePolicytoVolumeConfigpackages/appkit/src/index.tspolicyfrom the top-level barrelapps/dev-playground/server/index.tspolicy.allowAll()on the default volumedocs/docs/plugins/files.mdTest scenarios (via dev-playground)
policy.allowAll()volume — all CRUD operations succeed (list, read, upload, delete, mkdir)policy.publicRead()volume (default) — reads succeed, writes return403policy.denyAll()volume — all operations return403x-forwarded-userheader in production — returns401before policy is evaluatedPromise<boolean>is awaited correctlyappkit.files("vol").asUser(req).list()enforces policy with user identity;appkit.files("vol").list()enforces with{ isServicePrincipal: true }content-lengthis passed asresource.sizeto the policy functionpolicy.all()short-circuits on first deny,policy.any()short-circuits on first allow,policy.not()invertsTest plan
policy.test.ts— 136 lines, covers all helpers + async +PolicyDeniedError)plugin.test.ts— 376 new lines covering routes, SDK API, SP identity, user identity, 401/403 responses)pnpm devwith the dev-playgroundThis pull request was AI-assisted by Isaac.