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-21/

Regal: Annotations — RBAC Authorization Policy

Write a fully annotated Rego policy in the package rbac.authz with metadata annotations:

  1. Package annotation with title, description, and authors fields
  2. allow rule annotated with title, description, and entrypoint: true
  3. user_role rule annotated with title and description

The policy logic:

  • default allow := false
  • Allow when the user has a role and that role includes the required permission
  • user_role returns the role from data.user_roles[input.user]
  • Required permission is derived from the action and resource in input

Metadata blocks must be immediately above the rule they annotate — no blank lines between the # METADATA block and the rule.

Input

{
  "user": "alice",
  "action": "read",
  "resource": "reports"
}

Data

{
  "user_roles": {"alice": "engineer"},
  "role_permissions": {"engineer": ["reports:read"]}
}

Expected behaviour

  • alice with read on reports → allow (has reports:read)
  • alice with write on reports → deny (no reports:write)
  • Unknown user → deny

README.md

rules.md

tile.json