@glinr/theauth-gateway
v3.0.2
Published
Standalone auth proxy for TheAuth - enforces auth, authorization, and audit in front of any API or MCP server
Maintainers
Readme
@glinr/theauth-gateway
Standalone auth proxy that enforces TheAuth policies in front of any HTTP service.
Install
npm install @glinr/@glinr/theauth-gatewayUsage
Create a gateway with route policies, then call handle on every incoming request.
import { createGateway, loadConfigFile } from '@glinr/theauth-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.theauth.com/gateway
License
MIT
