OPAL (Open Policy Administration Layer)

repository·master·Indexed 26 days ago

https://github.com/permitio/opal

An Open Policy Administration Layer designed to synchronize policy engines, such as OPA and AWS Cedar, with real-time changes in policy and data. OPAL uses a client-server architecture where OPAL-Servers detect updates in data sources (APIs, DBs, Git, S3) and notify OPAL-clients via a WebSocket PubSub channel to fetch the latest data.

Tokens
47.6K
Snippets
125
Records
294
Agent score
87%

What's inside OPAL

  1. What is Permit OPAL+

    master

    Permit OPAL+ is an enterprise software service package provided by Permit Inc. It is designed for enterprise users who require additional capabilities beyond the open-source OPAL project.

    Key offerings include:

    • Early access to features via a special license for an internal OPAL version.
    • Hosted OPAL servers.
    • Hosted policy decision points (OPAL-client + OPA / Cedar).
    • Direct influence on the project roadmap.
    • Dedicated support channels and custom SLAs.
    • Professional services and custom data-fetcher providers (including NRE).
  2. Overview of OPAL (Open Policy Administration Layer)

    master
    OPAL is an administration layer designed for Policy Engines like Open Policy Agent (OPA) and AWS Cedar Agent. It provides real-time synchronization by detecting changes to policies and policy data (from sources like APIs, databases, git, S3, or SaaS services) and pushing live updates to your agents. This ensures your services remain in sync with the latest authorization data and policies required by live applications.
  3. Introduction to OPAL

    master

    OPAL (Open Policy Administration Layer) is a tool designed to supercharge Open Policy Agent (OPA) by providing real-time updates for both policy and data. While OPA decouples policy from code, OPAL ensures that the authorization layer stays in sync with live application state changes (such as user clicks or API calls) using Websocket Pub/Sub.

    Key capabilities include:

    • Real-time updates: Uses Websocket Pub/Sub to push policy and data changes to policy agents.
    • Decoupling: Separates policy (typically git-driven) from data (via distributed data-source fetching engines).
    • Cloud-native architecture: Designed for microservices and distributed environments.
  4. Overview of OPAL Architecture

    master

    OPAL (Open Policy Administration Layer) uses a client-server stateless architecture to keep policy engines (like OPA or AWS Cedar Agent) in sync with real-time changes in policy and data.

    How it works:

    1. OPAL-Servers detect changes in policy or data sources (APIs, DBs, Git, S3, etc.).
    2. OPAL-Servers publish updates over a lightweight WebSocket PubSub channel.
    3. OPAL-clients subscribe to specific topics via the PubSub channel.
    4. Upon receiving an update, each OPAL-client fetches the data directly from the source to load it into its managed Policy Engine instance.
  5. Understand the difference between Policies and Dynamic Data

    master

    OPAL clients manage two distinct types of data sources:

    1. Policies (and static data): These are policy bundles (similar to OPA native bundles) containing Rego policies and data that rarely changes. The default source is a Git repository, or an API server exposing tar bundles.

    2. Dynamic Data: These are DataSourceEntry objects which act as "directives" telling OPAL how to fetch real-time data (e.g., from a database or 3rd party API) and where to place it in the OPA document tree. OPAL_DATA_CONFIG_SOURCES contains these directives.

  6. Understand OPAL Architecture

    master

    OPAL (Open Policy Administration Layer) consists of two primary components that work together to keep policy engines (like OPA) synchronized with policies and authorization data:

    OPAL Server

    • Policy Tracking: Monitors a versioned repository (e.g., Git, S3, SVN) via webhooks or polling for policy updates.
    • Data Notifications: Accepts data update notifications via a REST API.
    • Update Distribution: Pushes updates (as diffs) to clients via a Pub/Sub channel.
    • Scalability: Supports scaling via a backbone Pub/Sub (Postgres, Redis, or Kafka).

    OPAL Client

    • Deployment: Runs at the edge alongside a policy agent (e.g., OPA).
    • Synchronization: Subscribes to Pub/Sub updates for specific data and policy topics.
    • Data Fetching: Downloads data-source configurations from the server and fetches data directly from multiple sources (DBs, APIs, 3rd party services) to aggregate it for the policy agent.
    • Policy Management: Downloads and keeps the policy agent up to date with the latest policies.
  7. Understand OPAL's Realtime Architecture

    master

    OPAL manages authorization layers in realtime using a Websocket Pub/Sub channel between OPAL-clients and OPAL-servers.

    Key architectural characteristics:

    • Realtime Updates: Each OPAL-client (and its associated policy agent) subscribes to a websocket channel to receive instant updates.
    • Statelessness: Both OPAL-clients and OPAL-servers are stateless to support scaling. State is maintained in the end components (e.g., the OPA agent acting as an edge cache) and the original data sources (e.g., Git, databases).
    • Networking: OPAL uses outgoing websocket connections to establish Pub/Sub channels, which helps bypass most routing and firewall concerns.
  8. Understand the OPAL architecture and workflow

    master

    OPAL operates using a server-client model to manage policy and data for policy agents (such as OPA, Cedar-agent, or AWS AVP):

    1. OPAL Server: Acts as the central orchestrator. It tracks policy changes (from Git or API bundle servers) and data changes (from webhooks or Fetch-Providers).
    2. OPAL Clients: Subscribe to the server via pub/sub over websockets. The server sends instructions to clients to load new policies or data.
    3. Policy Agents: Managed by the OPAL clients, these agents (e.g., OPA, Cedar-agent) receive the loaded policy and data to perform authorization decisions.

    When an OPAL client or policy agent restarts, both policy and data are loaded from scratch.

  9. Quickstart OPAL with Docker Compose

    master

    The fastest way to run a working configuration of both OPAL server and OPAL client on your local machine is to use the provided Docker Compose example. This command downloads the example configuration and starts the services immediately.

    curl -L https://raw.githubusercontent.com/permitio/opal/master/docker/docker-compose-example.yml \
    > docker-compose.yml && docker compose up
  10. Implement an External Data Source API server

    master

    When using an external data source, your API server must perform the following steps:

    1. Expose an HTTP GET endpoint matching the path provided in the OPAL configuration.
    2. Extract the JWT: Retrieve the OPAL client JWT from the token query parameter.
    3. Validate the JWT: Use the OPAL public key to verify the token's authenticity.
    4. Determine Configuration: Use custom claims within the validated JWT to decide which DataSourceEntry configuration to return to that specific client.
    5. Return JSON: Respond with a JSON object representing the OPAL_DATA_CONFIG_SOURCES (the list of actual data source entries) for that client.