Skip to content

Commit

Permalink
feat: Initial OpenFgaClientConfig (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyjames committed Mar 6, 2024
2 parents 1fadf8a + 407676f commit 64f69ff
Show file tree
Hide file tree
Showing 14 changed files with 951 additions and 17 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Checks

on: [pull_request, push]

jobs:
build:
name: Run Checks
runs-on: ubuntu-latest
steps:
- name: Checkout the source
uses: actions/checkout@v4
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Run Gradle check task
run: ./gradlew check --continue
31 changes: 16 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# exclude jar for gradle wrapper
!gradle/wrapper/*.jar
!**/gradle/wrapper/*.jar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

# build files
**/target
target
.gradle
build

# JetBrains IDEs
.idea/
*.iml

.DS_Store
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,55 @@
# fga-spring-boot
A Spring Boot Starter for OpenFGA
# OpenFGA Spring Boot Starter

A Spring Boot Starter for OpenFGA.

## Configuration

No authorization:

```yaml
openfga:
api-url: YOUR_FGA_API_URL
store-id: YOUR_FGA_STORE_ID
authorization-model-id: YOUR_FGA_AUTHORIZATION_MODEL_ID
```
API token authorization:
```yaml
openfga:
api-url: YOUR_FGA_API_URL
store-id: YOUR_FGA_STORE_ID
authorization-model-id: YOUR_FGA_AUTHORIZATION_MODEL_ID
credentials:
method: API_TOKEN
config:
api-token: YOUR_API_TOKEN
```
Client credentials authorization:
```yaml
openfga:
api-url: YOUR_FGA_API_URL
store-id: YOUR_FGA_STORE_ID
authorization-model-id: YOUR_FGA_AUTHORIZATION_MODEL_ID
credentials:
method: CLIENT_CONFIGURATION
config:
client-id: YOUR_CLIENT_ID
client-secret: YOUR_CLIENT_SECRET
api-token-issuer: YOUR_API_TOKEN_ISSUER
api-audience: YOUR_API_AUDIENCE
scopes: YOUR_SPACE_SEPERATED_SCOPES
```
Your application can then inject the configured `openFgaClient`:

```java
@Service
public class MyService {
@Autowired
private OpenFgaClient openFgaClient;
}
```
49 changes: 49 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
id 'java-library'
id 'org.springframework.boot' version '3.2.2' apply false
id 'io.spring.dependency-management' version '1.1.4'

id 'maven-publish'
}

group = "dev.openfga"
version = "0.0.1-SNAPSHOT"

sourceCompatibility = 17
targetCompatibility = 17

repositories {
mavenCentral()
}

test {
useJUnitPlatform()
}

dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot'
implementation 'org.springframework.boot:spring-boot-autoconfigure'
api 'dev.openfga:openfga-sdk:0.4.0'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.hamcrest:hamcrest:2.2'

}

publishing {
publications {
maven(MavenPublication) {
groupId = "${groupId}"
artifactId = 'openfga-spring-boot-starter'
version = "${version}"

from components.java
}
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 64f69ff

Please sign in to comment.