Policies
Policies, written as Open Policy Agent (OPA) Policies in Rego, define if someone should get access.
There are two types of Policies:
Access Policies define if someone should get access.
Workflow Policies define if a Workflow Step should be skipped.
Polices Spec
Access Policies
Workflow Policies
Configuring Policies For Your Grant Kit
Access Policies and Workflow Policies are configured in identical ways.
For Access Policies, put your policies in the
policies
attribute.For Workflow Policies, use the
skip_if
attribute.
These attributes represent a list of OPA Policies as either a bundle
or a query
.
Bundles
A Bundle is a native OPA Bundle that represents a group of OPA Policies. Bundles are typically either a directory or a gzipped tarball.
Bundles are configured using an RFC 3986 URI string for the bundle
attribute. This string must point to the location of your bundle in your code repository.
Bundle Spec
Currently Abbey supports the github://
scheme. Future schemes such as file://
, s3://
, and https://
coming soon.
Organizing Bundles
Bundles are great for distributing and reusing policies.
Before building bundles, you should first organize your policies into a directory structure that represents the functionality of the bundle, for example:
The above setup has a policies
directory that contains 2 bundles, each with 1 package in them. The bundles contain a .manifest
file to define the packages it knows about and is used to avoid package conflicts.
.manifest
files are required if you're using OPA bundles. They help avoid package conflicts. As we add more packages, we add their paths to the .manifest
file.
Building Bundles
Once you have your directory set up, you can build your bundles using the OPA CLI, for example:
Queries
A Query represents a single OPA Policy. Queries are typically used for simple one-off rules that don't require the hierarchical rule organization that Bundles provide and aren't intended to be distributed.
Queries are configured by writing native Rego code directly as a string, typically a multiline Heredoc string for better visibility.
Queries must be defined using the main
namespace for Abbey to evaluate it.
Writing Policies For Your Grant Kit
Policies are implemented using the Abbey OPA Constraint Framework. This Framework is simplified subset of the OPA Constraint Framework that makes working with OPA and Rego easier.
Writing Policies consists of three steps:
Define Your Logic Using Rego
Access Policies and Workflow Policies are implemented using identical schemas.
Writing Access Policies
Access Policies are written using the following schema:
Automatic Revocation
Once access is granted, Abbey will continuously monitor your policies and revoke access in realtime if they evaluate to false. This may happen if you set an expiration through functions.expire_at
or functions.expire_after
, a user's attribute has changed (e.g., they went off-call), or infrastructure has changed (e.g., a database was now marked as sensitive). You get this functionality out-of-the-box without having to configure anything extra.
Writing Workflow Policies
Workflow Policies are written using the following schema:
Use Policy Inputs and Enriched Data In Your Logic
In order to write meaningful policies, you need to be able to compare properties across different systems.
For example, you might want to create a policy that denies access to a sensitive database table by default, unless they're an engineer and active on an on-call rotation. "Sensitive database table", "engineer", and "active on an on-call rotation" are properties from systems such as Terraform Plan, GitHub Teams, and PagerDuty Schedules.
Abbey provides two categories of external data for you when writing your policies:
Policy Inputs
Policy Inputs represent the Terraform Plan output that contains the preview of changes that Terraform plans to make to your infrastructure. This allows you to write policies based on what your infrastructure looks like.
Usage
To use Policy Inputs, use the
input
object in your Rego code.
For example, given the following Terraform Plan output as your input
:
You can define an Access Policy that automatically denies access to anyone attempting to get access to the PII_READONLY
role:
The input
schema is native to Terraform and has many other attributes available for you to use.
input
is accessible for both Access Policies and Workflow Policies.
Enriched Data
Enriched Data represents properties from external applications that generally contain information about who someone is. This allows you to write policies based on roles, relationships, or attributes of a person. Abbey automatically enriches data for you, based on identities you or your admin have imported into Abbey. For more information about importing application data, go toLink Identities.
Usage
To use Enriched Data, use the
data
object in your code with theuser
namespace.
For example, given the following data
:
You can define an Access Policy that automatically denies access to someone if they're not on-call:
The data
schema is a component of the Abbey OPA Constraint Framework. As you connect more systems to the Abbey Platform, Abbey will automatically pick them up and enrich the data for you to use in your policies.
data
is accessible in all Policy types: Access, Revocation, and Workflow.
Policy Evaluation
Abbey evaluates your policies using Abbey's distributed Policy Evaluation Engine. This engine will evaluate your Access, Revocation, and Workflow Policies.
Policy Evaluation has four stages:
Get Policy Input.
This is typically the output of your
tfplan.json
from yourterraform plan
command.
Fetch and enrich Data.
Abbey will automatically fetch and enrich data for any system you have connected.
Evaluate your OPA Policies.
Pass in your Policy Input and Enriched Data as parameters.
Output evaluation results and warning details.
Output a single boolean value along with a key-value object of evaluation and warning details.
Guardrail Policies
Abbey supports reusable policies that can be distributed using Bundles. You can leverage this feature to provide Guardrail Policies. These are policies that can be imported into other policies and cannot be overridden.
There are two primary use cases:
You're a member of a security or IT team that wants to instill set guardrails around access for the rest of your company. For example, set some sort of non-overridable policy around PII data.
You don't want to write your own policies. Instead, you prefer to leverage existing, battle-tested policies. For example, you can pass in an OPA
bundle
in your Grant Kit that already has all the necessary Rego rules for compliance for a specific target system.
To create a Guardrail Policy, create a policy or bundle as you would normally and import it into any other policy you want to use in your Grant Kits.
Troubleshooting
A common deployment failure for grant kits is a misconfigured bundle
field in the policies
block
Double check it starts with
github://
Double check repository and username or org name is correct
These fields are case-sensitive so double check any upper/lowercase letters
Double check for any extra
:
or/
'sDouble check the path to your policies exists
Last updated