A Fastify plugin that integrates Casbin authorization using a RESTful model. As of version 4.0.0, it builds on top of fastify-casbin to enforce access control based on subject, object, and action extracted from HTTP requests. It provides route-level enabling, customizable extractors, and hooks for allow/deny actions. Released by NearForm, it is actively maintained with TypeScript definitions included. Unlike generic Casbin adapters, this plugin is opinionated for REST APIs and tightly couples with Fastify's lifecycle for minimal boilerplate.
npm install fastify-casbin-restNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows registering fastify-casbin and fastify-casbin-rest with custom extractors and a route protected by Casbin REST authorization.
Use casbin.rest: true or casbin.rest: { ... } instead of casbin.rest.enabled: true.Ensure fastify-casbin is registered before fastify-casbin-rest in your plugin chain.
Provide getDom in plugin options or route options if your Casbin model uses domains.
Use synchronous callbacks only.
npm install fastify-casbin
Ensure app.register(fastifyCasbin, ...) is called before app.register(fastifyCasbinRest, ...)
Set casbin.rest to true or an object with extraction functions.