Skip to main content
Version: 1.x

@core/access-policy

The @core/access-policy plugin generates access policy guard objects from policy rules (defined using @@allow and @@deny attributes).

info

This plugin is always automatically included when zenstack generate is run. You only need to add it to your ZModel if you want to customize its options.

Installation

This plugin is built-in to ZenStack and does not need to be installed separately.

Options

NameTypeDescriptionRequiredDefault
outputStringOutput directory (relative to the path of ZModel)Nonode_modules/.zenstack
compileBooleanIf the generated TS code should be compiled to JSNotrue
preserveTsFilesBooleanIf the generated TS files should be preserved (after compiled to JS)Notrue if compile is set to false, otherwise false

Example

/schema.zmodel
plugin policy {
provider = '@core/access-policy'
output = 'src/lib/zenstack'
compile = false
}

Runtime APIs like enhance and withPolicy depend on the output of this plugin and by default load it from the default output location. If you customize the output location, you need to load and pass it manually:

const policy = require('./lib/zenstack/policy').default;
const db = enhance(prisma, { user }, policy);
Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below