@kavachos/gateway
v2.0.0
Published
Standalone auth proxy for KavachOS - enforces auth, authorization, and audit in front of any API or MCP server
Maintainers
Readme
@kavachos/gateway
Standalone auth proxy that enforces KavachOS policies in front of any HTTP service.
Install
npm install @kavachos/gatewayUsage
Create a gateway with route policies, then call handle on every incoming request.
import { createGateway, loadConfigFile } from '@kavachos/gateway';
const gateway = createGateway({
kavachApiUrl: 'https://auth.yourapp.com',
tenantId: 'your-tenant-id',
upstream: 'http://localhost:3001',
policies: [
{
match: { path: '/api/**', methods: ['GET', 'POST'] },
require: { permissions: ['api:access'] },
rateLimit: { requests: 100, windowMs: 60_000 },
},
],
});
// Node HTTP server
import { createServer } from 'http';
createServer((req, res) => gateway.handle(req, res)).listen(8080);File-based config
const config = await loadConfigFile('./kavach-gateway.json');
const gateway = createGateway(config);Exports
createGateway— creates a gateway instanceloadConfigFile— loads gateway config from a JSON/YAML filematchPolicy— utility to test a request against a policy
Docs
https://docs.kavachos.com/gateway
License
MIT
