@cshield/pep-fastify
@cshield/pep-fastify
Fastify plugin for ContractShield policy enforcement.
Installation
npm install @cshield/pep-fastifyPlugin
contractshieldPlugin
Register the ContractShield plugin with Fastify.
import Fastify from 'fastify';import { contractshieldPlugin } from '@cshield/pep-fastify';
const app = Fastify();
await app.register(contractshieldPlugin, { policy: './policy.yaml', identityExtractor: (request) => ({ authenticated: !!request.user, subject: request.user?.id })});Options
Same as Express adapter. See @cshield/pep-express.
Accessing Decisions
app.get('/api/resource', async (request, reply) => { const { decision, context } = request.contractshield;
return { data: 'success' };});