Open Policy Agent REST connector

Usage no npm install needed!

<script type="module">
  import ohPa from 'https://cdn.skypack.dev/oh-pa';



A Nodejs library for interacting with the Open Policy Agent (OPA) REST API.

This project is experimental and there will likely be major breaking changes unti we reach 1.0.


I wanted to build a zero dependency package that simplifies access to the OPA REST API.


npm install --save oh-pa


query - for adhoc policy decisions

Need a decision made with data that OPA has but don't need/want/have a named policy? This is the function to use.

'use strict'

const { query } = require('oh-pa')

query('x = data.example.allow')

data - for named policy decisions

Use named policies to make decisions using stored data and/or input.

'use strict'

const { data } = require('oh-pa')

data('opa.examples.allow_request', { example: { flag: true } })
// NOTE: you can also use slashes instead of periods - opa/examples/allow_request