Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Outline

Example Policy Bundle

This directory contains a simple OPA policy and a pre-built IR bundle for use with the SDK examples.

Policy

policy.rego defines a rule example/allow that grants access when:

  • The user is "admin", or
  • The action is "read" and the user is in the authorized_readers list

data.json provides the static data:

{
    "authorized_readers": ["alice", "bob", "charlie"]
}

Example Evaluations

Input Result Reason
{"user": "admin", "action": "write"} true admin always allowed
{"user": "alice", "action": "read"} true alice is an authorized reader
{"user": "alice", "action": "write"} false alice can only read
{"user": "eve", "action": "read"} false eve is not an authorized reader

Rebuilding the Bundle

If you modify the policy or data, rebuild with:

cd examples
opa build -t plan -e 'example/allow' -b . -o bundle.tar.gz
Morty Proxy This is a proxified and sanitized view of the page, visit original site.