Subscribe to the Non-Human & AI Identity Journal
Governance, Ownership & Risk

Rego

← Back to Glossary
By NHI Mgmt Group Updated June 9, 2026 Domain: Governance, Ownership & Risk

Rego is OPA’s declarative policy language for expressing what conditions permit or deny a request. It works well with structured data such as JSON and YAML, and its deterministic evaluation model makes it suitable for real-time authorization and compliance decisions.

Expanded Definition

Rego is the policy language used by Open Policy Agent to express authorization logic as conditions over structured inputs, making it a fit for NHI decisions that must be evaluated consistently against JSON, YAML, and other machine-readable context. In NHI and IAM workflows, Rego typically describes who or what may act, under which conditions, and with which constraints. Its strength is not just expressiveness, but deterministic evaluation, which supports repeatable allow or deny outcomes across services and pipelines. That makes it useful for service-to-service access, deployment gates, secrets usage checks, and compliance rules tied to machine identities. Definitions vary across vendors on whether Rego is best described as a policy language, a policy-as-code implementation detail, or the central policy layer itself, so the term should be used precisely. For governance mapping, the operational question is whether Rego is encoding policy intent faithfully and consistently with broader controls such as the NIST Cybersecurity Framework 2.0. The most common misapplication is treating Rego as a replacement for identity design, which occurs when teams write policy rules before defining authoritative NHI attributes and trust boundaries.

Examples and Use Cases

Implementing Rego rigorously often introduces policy maintenance overhead, requiring organisations to balance fine-grained control against the cost of keeping policy logic aligned with changing services and identities.

  • Service account authorization in Kubernetes, where Rego checks namespace, workload labels, and allowed actions before a request is admitted.
  • Secrets access governance, where policy evaluates whether a workload may retrieve a token from a vault based on environment, ownership, and request context.
  • Deployment approval gates, where Rego denies a pipeline step if an NHI is over-privileged or lacks the required attestation status, reinforcing lessons from the Ultimate Guide to NHIs.
  • API authorization, where structured claims and workload metadata are compared before a service-to-service call is accepted, aligning with policy checks described in the NIST Cybersecurity Framework 2.0.
  • Compliance-as-code, where Rego expresses prohibited combinations such as long-lived credentials, exposed environments, or missing rotation evidence.

Used well, Rego becomes the enforcement layer that turns NHI governance into executable rules rather than documentation that drifts from reality.

Why It Matters in NHI Security

Rego matters because NHI environments fail quickly when authorization logic is scattered across services, hardcoded in applications, or implemented differently by each platform team. A single declarative policy layer reduces ambiguity around what an agent, service account, or workload may do, which is critical when privileged automation can move faster than manual review. This is especially important in NHI security because identity sprawl, over-privilege, and secret misuse are common failure modes. In the Ultimate Guide to NHIs, NHI Mgmt Group reports that 97% of NHIs carry excessive privileges, increasing unauthorised access and broadening the attack surface. Rego helps counter that risk by making least privilege measurable and testable, but only if inputs are authoritative and policy logic is reviewed like production code. It also supports governance alignment with the NIST Cybersecurity Framework 2.0 by making access decisions auditable. Organisations typically encounter the urgency of Rego only after an over-privileged workload or misrouted secret causes an incident, at which point policy-as-code becomes operationally unavoidable to address.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-02Rego often enforces secret and credential access rules central to NHI-02.
NIST CSF 2.0PR.AC-4Rego operationalizes least privilege and access enforcement for machine identities.
NIST Zero Trust (SP 800-207)PAPolicy enforcement is a core Zero Trust function, which Rego can implement in code.

Use Rego to codify NHI access checks and block secret retrieval when policy conditions are not met.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on June 9, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org