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 <>
Latest commit 6efac9f Apr 10, 2019

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.


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


Install the dependencies into a virtualenv:

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


Open a new window and run OPA:

opa run -s example.rego

Start the server:

source env/bin/activate
python data_filter_example/

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


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.