oh-pa

Open Policy Agent REST connector

Usage no npm install needed!

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

README

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.

Why

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

Install

npm install --save oh-pa

Usage

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')
  .then(console.log)
  .catch(console.error)

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
  .then(console.log)
  .catch(console.error)