0.2.0 • Published 3 years ago

oh-pa v0.2.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
3 years ago

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)
0.2.0

3 years ago

0.1.0

4 years ago