All Projects → Bisnode → opa-java-client

Bisnode / opa-java-client

Licence: Apache-2.0 license
No description or website provided.

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects
kotlin
9241 projects

Projects that are alternatives of or similar to opa-java-client

pre-commit-opa
Pre-commit git hooks for Open Policy Agent (OPA) and Rego development
Stars: ✭ 53 (+112%)
Mutual labels:  opa, openpolicyagent
opa-kafka-plugin
Open Policy Agent (OPA) plug-in for Kafka authorization
Stars: ✭ 46 (+84%)
Mutual labels:  opa, openpolicyagent
opa-spring-security
Open Policy Agent for Spring Security
Stars: ✭ 19 (-24%)
Mutual labels:  opa, openpolicyagent
awesome-opa
A curated list of OPA related tools, frameworks and articles
Stars: ✭ 316 (+1164%)
Mutual labels:  opa, openpolicyagent
opal
Policy and data administration, distribution, and real-time updates on top of Open Policy Agent
Stars: ✭ 459 (+1736%)
Mutual labels:  opa
prancer-compliance-test
This repository includes cloud security policies for IaC and live resources.
Stars: ✭ 32 (+28%)
Mutual labels:  opa
fury-kubernetes-opa
Kubernetes Fury OPA. Policy enforcement for your Kubernetes Cluster
Stars: ✭ 34 (+36%)
Mutual labels:  opa
opa-docker-authz
A policy-enabled authorization plugin for Docker.
Stars: ✭ 67 (+168%)
Mutual labels:  opa
Gatekeeper
Gatekeeper - Policy Controller for Kubernetes
Stars: ✭ 2,194 (+8676%)
Mutual labels:  opa
OPA-python-client
Python client for Open Policy Agent
Stars: ✭ 24 (-4%)
Mutual labels:  opa
k8s-opa-boilerplate
Boilerplate example of managing OPA with kustomize
Stars: ✭ 14 (-44%)
Mutual labels:  opa
CKS-Exercises-Certified-Kubernetes-Security-Specialist
A set of curated exercises to help you prepare for the CKS exam
Stars: ✭ 124 (+396%)
Mutual labels:  opa
container-image-sign-and-verify-with-cosign-and-opa
This is just a proof-of-concept project that aims to sign and verify container images using cosign and OPA (Open Policy Agent)
Stars: ✭ 54 (+116%)
Mutual labels:  opa
riskybird
Regular expression authors best friend
Stars: ✭ 48 (+92%)
Mutual labels:  opa
dotnet-opa-wasm
Call Open Policy Agent (OPA) policies in WASM (Web Assembly) from .NET Core
Stars: ✭ 36 (+44%)
Mutual labels:  opa
Opa
An open source, general-purpose policy engine.
Stars: ✭ 5,939 (+23656%)
Mutual labels:  opa
regolibrary
The rego library package contains the controls Kubescape uses for detecting miss-configurations in Kubernetes manifests
Stars: ✭ 45 (+80%)
Mutual labels:  opa
build-a-platform-with-krm
Build a platform with the Kubernetes resource model!
Stars: ✭ 55 (+120%)
Mutual labels:  openpolicyagent
runtime
an abstraction library on top of OPA
Stars: ✭ 22 (-12%)
Mutual labels:  opa
opa-java-spring-client
Simple Spring client for working with the Open Policy Agent
Stars: ✭ 19 (-24%)
Mutual labels:  opa

opa-java-client

Maven Central build

OPA java client is a wrapper for OPA REST API. The goal was to create client that is lightweight and framework independent. It's built for current Bisnode needs, including:

  • creating documents
  • creating policies
  • querying for documents

Installation

Prerequisites: Java 11 or higher

Add library using maven:

<dependency>
    <groupId>com.bisnode.opa</groupId>
    <artifactId>opa-java-client</artifactId>
    <version>{version}</version>
</dependency>

or Gradle

implementation 'com.bisnode.opa:opa-java-client:{version}'

Usage

Our library is using Jackson for (de)serialization so, objects that you are passing/retrieving using this client should have either proper Jackson-friendly configuration or - the solution working in most cases - getters and setters for fields you want to pass/retrieve to/from OPA. More information about Jackson.

Query for document

        OpaQueryApi client = OpaClient.builder()
                                .opaConfiguration("http://localhost:8181")
                                .build();

        DesiredResponse response = client.queryForDocument(new QueryForDocumentRequest(yourDTO, "path/to/document"), DesiredResponse.class);
        
        // Do whatever you like with the response

####Example Example project is in examples/query-for-document directory.

Create policy

        OpaPolicyApi client = OpaClient.builder()
                                     .opaConfiguration("http://localhost:8181")
                                     .build();

        void createOrUpdatePolicy(new OpaPolicy("your_policy_id", "content of the policy"));

Create document

        OpaDataApi client = OpaClient.builder()
                                     .opaConfiguration("http://localhost:8181")
                                     .build();

        void createOrOverwriteDocument(new OpaDocument("path/to/document", "content of document (json)"));

Error handling

Error handling is done via exceptions. This means that if any error occurs, runtime exception which is subclass of OpaClientException is thrown. For now, there is simple error message returned.

OpaServerConnectionException is thrown when connection problems with OPA server occur.

Interface segregation

Every OPA (Data, Policy, Query) API has it's own interface. So, for example, if you want to use client only for querying, you can use OpaQueryApi as projection. Thanks to that, in your code there will be exposed only methods that are needed by you, while not allowing to mess with policies and data.

Available interface projections:

  • OpaQueryApi
  • OpaPolicyApi
  • OpaDataApi

Developing and building

Build process and dependency management is done using Gradle. Tests are written in spock.

Contribution

Interested in contributing? Please, start by reading this document.

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].