-
-
Save tsandall/ddaf1087aa2baf3df98c33e1dc7d62ee to your computer and use it in GitHub Desktop.
ALFA comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package example | |
| default allow = false | |
| allow { | |
| input.action = "GET" | |
| input.path = "/index.html" | |
| allowed_roles := ["guest", "user", "admin"] | |
| input.subject.roles[_] = allowed_roles[_] | |
| } | |
| allow { | |
| input.action = "GET" | |
| input.path = "/motd" | |
| allowed_roles := ["user", "admin"] | |
| input.subject.roles[_] = allowed_roles[_] | |
| } | |
| allow { | |
| input.action = "POST" | |
| input.path = "/motd" | |
| input.subject.roles[_] = "admin" | |
| } | |
| allow { | |
| input.action = "GET" | |
| input.path = "/admin" | |
| input.subject.roles[_] = "admin" | |
| } | |
| allow { | |
| input.action = "GET" | |
| input.path = "/stats" | |
| input.subject.ip = "127.0.0.1" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package example | |
| default allow = false | |
| # Define RBAC permission data structure. | |
| # Hardcoded into policy for clarity, but could | |
| # be supplied as raw JSON data and kept in-memory | |
| # by the OPA. | |
| roles = { | |
| "/index.html": { | |
| "GET": ["guest", "user", "admin"], | |
| }, | |
| "/motd": { | |
| "GET": ["user", "admin"], | |
| "POST": ["admin"], | |
| }, | |
| "/admin": { | |
| "GET": ["admin"], | |
| } | |
| } | |
| # Interpret RBAC permission data structure. | |
| allow { | |
| input.subject.roles[_] = roles[input.path][input.action][_] | |
| } | |
| # Handle ABAC scenario. | |
| allow { | |
| input.action = "GET" | |
| input.path = "/stats" | |
| input.subject.ip = "127.0.0.1" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment