Skip to content
Branch: master
Find file History
xevix and tsandall Update data_filter_example docs to match example.rego.
The docs in the data_filter_example use lowercase for the HTTP method,
which is internally consistent, but inconsistent with the example.rego
used. Instead, use uppercase in the doc example to match.

Fixes #53

Signed-off-by: Alejandro Wainzinger <aikawarazuni@gmail.com>
Latest commit 6efac9f Apr 10, 2019

README.md

Data Filter Example

This directory contains a sample server that uses OPA's Compile API to perform data filtering and authorization. When the server receives API requests it asks OPA for a set of conditions to apply to the SQL query that serves the request.

The server itself is implemented in Python using Flask and and sqlite3.

Status

The Rego → SQL translation implemented in this directory should be considered experimental and is only tested against sqlite.

Install

Install the dependencies into a virtualenv:

virtualenv env
source env/bin/activate
pip install -r requirements.txt
pip install -e .

Testing

Open a new window and run OPA:

opa run -s example.rego

Start the server:

source env/bin/activate
python data_filter_example/server.py

The server listens on :5000 and serves an index page by default.

Development

To run the integration tests, start OPA in another window (opa run -s) and then:

pytest .
You can’t perform that action at this time.