CtrlK
BlogDocsLog inGet started
Tessl Logo

nicholasjackson/opa-rego-language

Rego is the declarative policy language used by Open Policy Agent (OPA). This tile covers writing and testing Rego policies for Kubernetes admission control, Terraform and infrastructure-as-code plan validation, Docker container authorization, HTTP API authorization, RBAC and role-based access control, data filtering, metadata annotations with opa inspect, and OPA policy testing with opa test.

99

1.19x

Quality

Pending

Does it follow best practices?

Impact

99%

1.19x

Average score across 31 eval scenarios

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

task.mdevals/scenario-4/

Access Control: RBAC Policy

Write a Rego policy for our infrastructure platform. The user's roles come from their JWT claims. Role permissions are loaded into OPA's data document.

Input

{
  "user": "bob",
  "token": {
    "sub": "bob",
    "roles": ["devops", "network_admin"]
  },
  "action": "deploy",
  "resource_type": "application"
}

Data

data.role_grants maps each role to the actions and resource types it permits:

{
  "auditor": [
    {"action": "view", "resource_type": "logs"}
  ],
  "devops": [
    {"action": "view",   "resource_type": "logs"},
    {"action": "deploy", "resource_type": "application"}
  ],
  "network_admin": [
    {"action": "configure", "resource_type": "network"}
  ]
}

Expected behaviour

  • bob (devops + network_admin) can deploy applications and configure network
  • A user with only auditor can view logs but not deploy
  • Nobody can do anything not covered by their role grants

README.md

rules.md

tile.json