Skip to content

Commit

Permalink
Update README and gradle description
Browse files Browse the repository at this point in the history
  • Loading branch information
chendrix committed Jul 25, 2024
1 parent 773928f commit 210e8ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 38 deletions.
43 changes: 7 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# OPA-SpringBoot
# OPA Spring Boot SDK

> [!IMPORTANT]
> The documentation for this SDK lives at [https://docs.styra.com/sdk](https://docs.styra.com/sdk), with reference documentation available at [https://styrainc.github.io/opa-springboot/javadoc](https://styrainc.github.io/opa-springboot/javadoc)

You can use the Styra OPA-SpringBoot SDK to connect [Open Policy Agent](https://www.openpolicyagent.org/) and [Enterprise OPA](https://www.styra.com/enterprise-opa/) deployments to your [Spring Boot](https://spring.io/projects/spring-boot) applications using the included [AuthorizationManager](https://docs.spring.io/spring-security/reference/servlet/authorization/architecture.html#_the_authorizationmanager) implementation. The policy inputs and outputs follow the [AuthZEN specification](https://openid.github.io/authzen).

> [!IMPORTANT]
> Would you prefer a plain Java API instead of Spring Boot? Check out [OPA-Java](https://github.com/StyraInc/opa-java).
> Would you prefer a plain Java API instead of Spring Boot? Check out the [OPA Java SDK](https://github.com/StyraInc/opa-java).
## SDK Installation

Expand All @@ -17,19 +16,18 @@ If you wish to build from source and publish the SDK artifact to your local Mave

On Linux/MacOS:

```
```shell
./gradlew publishToMavenLocal -Pskip.signing
```

On Windows:

```
```shell
gradlew.bat publishToMavenLocal -Pskip.signing
```

## SDK Example Usage (high-level)


```java
// ...

Expand Down Expand Up @@ -70,36 +68,9 @@ public class SecurityConfig {

```

## Policy Inputs & Outputs

In order to make OPA-SpringBoot compatible with [AuthZEN](https://openid.github.io/authzen), the policy inputs should be structured according to the following table:

| JSON Path | Description |
|-----------------------------|-------------|
| `input.subject.type` | Constant string `java_authentication` |
| `input.subject.id` | Spring authN [principal](https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/core/Authentication.html#getPrincipal()) |
| `input.subject.details` | Spring authN [details](https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/core/Authentication.html#getDetails()) |
| `input.subject.authorities` | Spring authN [authorities](https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/core/Authentication.html#getAuthorities()) |
| `input.resource.type` | Constant string `endpoint` |
| `input.resource.id` | Endpoint [servlet path](https://javadoc.io/static/jakarta.servlet/jakarta.servlet-api/5.0.0/jakarta/servlet/http/HttpServletRequest.html#getServletPath--) |
| `input.action.name` | HTTP request method |
| `input.action.protocol` | HTTP protocol for request |
| `input.action.headers` | HTTP headers for request |
| `input.context.type` | Constant string `http` |
| `input.context.host` | HTTP remote host of request |
| `input.context.ip` | HTTP remote IP of request |
| `input.context.port` | HTTP remote port for request |
| `input.context.data` | Optional supplemental data you can inject using a `ContextDataProvider` implementation |

... and the policy outputs must be structured according to the following table:

| JSON Path | Description |
|---------------------|-------------|
| `output.decision` | `true` if and only if the request should be allowed to proceed, else `false` |
| `output.context.id` | AuthZEN [Reason Object](https://openid.github.io/authzen/#name-reason-object) ID |
| `output.context.reason_admin` | AuthZEN [Reason Field Object](https://openid.github.io/authzen/#reason-field), for administrative use |
| `output.context.reason_user` | AuthZEN [Reason Field Object](https://openid.github.io/authzen/#reason-field), for user-facing error messages |
| `output.context.data` | Optional supplemental data provided by your OPA policy |
## Policy Input/Output Schema

Documentation for the required input and output schema of policies used by the OPA Spring Boot SDK can be found [here](https://docs.styra.com/sdk/springboot/reference/input-output-schema)

## Build Instructions

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ publishing {
from components.java

pom {
name = 'Styra Spring Boot SDK'
description = 'SDK enabling Spring Boot developers to easily integrate with the Styra API.'
name = 'OPA Spring Boot SDK'
description = 'The Styra-supported driver to connect Spring Boot applications to Open Policy Agent (OPA) and Enterprise OPA deployments'
url = 'https://github.com/styrainc/opa-springboot'
scm {
url = 'github.com/styrainc/opa-springboot'
Expand Down

0 comments on commit 210e8ee

Please sign in to comment.