All Projects → open-policy-agent → Opa Envoy Plugin

open-policy-agent / Opa Envoy Plugin

Licence: apache-2.0
A plugin to enforce OPA policies with Envoy

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Opa Envoy Plugin

Opa
An open source, general-purpose policy engine.
Stars: ✭ 5,939 (+3110.27%)
Mutual labels:  cloud-native, policy, authorization, compliance
speedle-plus
Speedle+ is an open source project for access management. It is based on Speedle open source project and maintained by previous Speedle maintainers.
Stars: ✭ 45 (-75.68%)
Mutual labels:  policy, authorization, compliance
Speedle
Speedle is an open source project for access control.
Stars: ✭ 153 (-17.3%)
Mutual labels:  policy, authorization, compliance
intercept
INTERCEPT / Policy as Code Static Analysis Auditing / SAST
Stars: ✭ 54 (-70.81%)
Mutual labels:  policy, compliance
fedramp-tailored
FedRAMP Tailored.
Stars: ✭ 40 (-78.38%)
Mutual labels:  authorization, compliance
meshery
Meshery, the cloud native manager
Stars: ✭ 1,587 (+757.84%)
Mutual labels:  cloud-native, envoy
spicedb
Open Source, Google Zanzibar-inspired fine-grained permissions database
Stars: ✭ 3,358 (+1715.14%)
Mutual labels:  authorization, cloud-native
OpenAM
OpenAM is an open access management solution that includes Authentication, SSO, Authorization, Federation, Entitlements and Web Services Security.
Stars: ✭ 476 (+157.3%)
Mutual labels:  policy, authorization
HeimGuard
🛡 A simple library that allows you to easily manage permissions in your .NET projects.
Stars: ✭ 77 (-58.38%)
Mutual labels:  policy, authorization
opal
Policy and data administration, distribution, and real-time updates on top of Open Policy Agent
Stars: ✭ 459 (+148.11%)
Mutual labels:  policy, authorization
Ambassador
open source Kubernetes-native API gateway for microservices built on the Envoy Proxy
Stars: ✭ 3,583 (+1836.76%)
Mutual labels:  cloud-native, envoy
Casbin Editor
Web-based model & policy editor for Casbin
Stars: ✭ 45 (-75.68%)
Mutual labels:  policy, authorization
Gloo
The Feature-rich, Kubernetes-native, Next-Generation API Gateway Built on Envoy
Stars: ✭ 3,219 (+1640%)
Mutual labels:  cloud-native, envoy
Authorizer
Simple Authorization via PHP Classes
Stars: ✭ 46 (-75.14%)
Mutual labels:  policy, authorization
Kuma
🐻 The Universal Service Mesh. CNCF Sandbox Project.
Stars: ✭ 2,516 (+1260%)
Mutual labels:  cloud-native, envoy
Patron
Patron - Access Control as a Service for OpenStack
Stars: ✭ 171 (-7.57%)
Mutual labels:  authorization
Externalsecret Operator
An operator to fetch secrets from cloud services and inject them in Kubernetes
Stars: ✭ 177 (-4.32%)
Mutual labels:  cloud-native
Casbin Server
Casbin as a Service (CaaS)
Stars: ✭ 171 (-7.57%)
Mutual labels:  authorization
Myapp
🖥️ How to build a Dockerized RESTful API application using Go.
Stars: ✭ 171 (-7.57%)
Mutual labels:  cloud-native
Huge
Simple user-authentication solution, embedded into a small framework.
Stars: ✭ 2,125 (+1048.65%)
Mutual labels:  authorization

opa-envoy-plugin

Build Status Go Report Card

This repository contains an extended version of OPA (OPA-Envoy) that allows you to enforce OPA policies with Envoy.

Issue Management

Use OPA GitHub Issues to request features or file bugs.

Examples with Envoy-based service meshes

The OPA-Envoy plugin can be deployed with Envoy-based service meshes such as:

Overview

OPA-Envoy extends OPA with a gRPC server that implements the Envoy External Authorization API. You can use this version of OPA to enforce fine-grained, context-aware access control policies with Envoy without modifying your microservice.

More information about the OPA-Envoy plugin including performance benchmarks, debugging tips, detailed usage examples can be found here.

Quick Start

This section assumes you are testing with Envoy v1.10.0 or later.

  1. Start Minikube.

    minikube start
    
  2. Install OPA-Envoy.

    kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/opa-envoy-plugin/master/quick_start.yaml
    

    The quick_start.yaml manifest defines the following resources:

    • A ConfigMap containing an Envoy configuration with an External Authorization Filter to direct authorization checks to the OPA-Envoy sidecar. See kubectl get configmap proxy-config for details.

    • OPA configuration file, and an OPA policy into ConfigMaps in the namespace where the app will be deployed, e.g., default.

    • A Deployment consisting an example Go application with OPA-Envoy and Envoy sidecars. The sample app provides information about employees in a company and exposes APIs to get and create employees. More information about the app can be found here. The deployment also includes an init container that installs iptables rules to redirect all container traffic through the Envoy proxy sidecar. More information can be found here.

  3. Make the application accessible outside the cluster.

    kubectl expose deployment example-app --type=NodePort --name=example-app-service --port=8080
    
  4. Set the SERVICE_URL environment variable to the service’s IP/port.

    minikube:

    export SERVICE_PORT=$(kubectl get service example-app-service -o jsonpath='{.spec.ports[?(@.port==8080)].nodePort}')
    export SERVICE_HOST=$(minikube ip)
    export SERVICE_URL=$SERVICE_HOST:$SERVICE_PORT
    echo $SERVICE_URL
    

    minikube (example):

    192.168.99.100:31380
    
  5. Exercise the sample OPA policy.

    For convenience, we’ll want to store Alice’s and Bob’s tokens in environment variables.

    export ALICE_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiZ3Vlc3QiLCJzdWIiOiJZV3hwWTJVPSIsIm5iZiI6MTUxNDg1MTEzOSwiZXhwIjoxNjQxMDgxNTM5fQ.K5DnnbbIOspRbpCr2IKXE9cPVatGOCBrBQobQmBmaeU"
    export BOB_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYWRtaW4iLCJzdWIiOiJZbTlpIiwibmJmIjoxNTE0ODUxMTM5LCJleHAiOjE2NDEwODE1Mzl9.WCxNAveAVAdRCmkpIObOTaSd0AJRECY2Ch2Qdic3kU8"
    

    Check that Alice can get employees but cannot create one.

    curl -i -H "Authorization: Bearer "$ALICE_TOKEN"" http://$SERVICE_URL/people
    curl -i -H "Authorization: Bearer "$ALICE_TOKEN"" -d '{"firstname":"Charlie", "lastname":"OPA"}' -H "Content-Type: application/json" -X POST http://$SERVICE_URL/people
    

    Check that Bob can get employees and also create one.

     curl -i -H "Authorization: Bearer "$BOB_TOKEN"" http://$SERVICE_URL/people
     curl -i -H "Authorization: Bearer "$BOB_TOKEN"" -d '{"firstname":"Charlie", "lastname":"Opa"}' -H "Content-Type: application/json" -X POST http://$SERVICE_URL/people
    

    Check that Bob cannot create an employee with the same firstname as himself.

     curl -i  -H "Authorization: Bearer "$BOB_TOKEN"" -d '{"firstname":"Bob", "lastname":"Rego"}' -H "Content-Type: application/json" -X POST http://$SERVICE_URL/people
    

Configuration

To deploy OPA-Envoy include the following container in your Kubernetes Deployments:

containers:
- image: openpolicyagent/opa:0.27.1-envoy
  imagePullPolicy: IfNotPresent
  name: opa-envoy
  volumeMounts:
  - mountPath: /config
    name: opa-envoy-config
  args:
  - run
  - --server
  - --addr=localhost:8181
  - --diagnostic-addr=0.0.0.0:8282
  - --config-file=/config/config.yaml
  livenessProbe:
    httpGet:
      path: /health?plugins
      port: 8282
  readinessProbe:
    httpGet:
      path: /health?plugins
      port: 8282

The OPA-Envoy configuration file should be volume mounted into the container. Add the following volume to your Kubernetes Deployments:

volumes:
- name: opa-envoy-config
  configMap:
    name: opa-envoy-config

Example Bundle Configuration

In the Quick Start section an OPA policy is loaded via a volume-mounted ConfigMap. For production deployments, we recommend serving policy Bundles from a remote HTTP server.

Using the configuration shown below, OPA will download a sample bundle from https://www.openpolicyagent.org. The sample bundle contains the exact same policy that was loaded into OPA via the volume-mounted ConfigMap.

config.yaml:

services:
  - name: controller
    url: https://www.openpolicyagent.org
bundles:
  envoy/authz:
    service: controller
plugins:
  envoy_ext_authz_grpc:
    addr: :9191
    path: envoy/authz/allow
    dry-run: false
    enable-reflection: false

You can download the bundle and inspect it yourself:

mkdir example && cd example
curl -s -L https://www.openpolicyagent.org/bundles/envoy/authz | tar xzv

In this way OPA can periodically download bundles of policy from an external server and hence loading the policy via a volume-mounted ConfigMap would not be required. The readinessProbe to GET /health?bundles ensures that the opa-envoy container becomes ready after the bundles are activated.

Dependencies

Dependencies are managed with Modules. If you need to add or update dependencies, modify the go.mod file or use go get. More information is available here. Finally commit all changes to the repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].