Skip to content

Commit

Permalink
feat: Initial version of the SPI for publising the events to the Open…
Browse files Browse the repository at this point in the history
…FGA platform.
  • Loading branch information
embesozzi committed Nov 9, 2023
1 parent d4b15e5 commit a6bfa5b
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 32 deletions.
31 changes: 31 additions & 0 deletions .github/tag-changelog-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
types: [
{ types: ["feat", "feature"], label: "✨ New Features" },
{ types: ["fix", "bugfix"], label: "🐛 Bugfixes" },
{ types: ["improvements", "enhancement"], label: "🔨 Improvements" },
{ types: ["perf"], label: "🏎️ Performance Improvements" },
{ types: ["build", "ci"], label: "🏗️ Build System" },
{ types: ["refactor"], label: "🪚 Refactors" },
{ types: ["doc", "docs"], label: "📚 Documentation Changes" },
{ types: ["test", "tests"], label: "🔍 Tests" },
{ types: ["style"], label: "💅 Code Style Changes" },
{ types: ["chore"], label: "🧹 Chores" },
{ types: ["other"], label: "Other Changes" },
],

excludeTypes: ["other"],

renderTypeSection: function (label, commits) {
let text = `\n## ${label}\n`;
commits.forEach((commit) => {
const scope = commit.scope ? `**${commit.scope}**: ` : ''
text += `- [\`${commit.sha.substring(0, 7)}\`](${commit.url}) ${scope} ${commit.subject}\n`;
});
return text;
},

renderChangelog: function (release, changes) {
const now = new Date();
return `# ${release} - ${now.toISOString().substr(0, 10)}\n` + changes + "\n\n";
},
};
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build-upload-release:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
discussions: write
steps:
- uses: actions/checkout@v3

- name: Get version from tag
id: version
run: echo ::set-output name=number::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d / -f 3 | sed -e 's/^v//')

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17

- name: Get jar name
id: get_name
run: echo "::set-output name=name::$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)"

- name: Build with maven
run: mvn clean package

- name: Create changelog text
id: changelog
uses: loopwerk/tag-changelog@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
exclude_types: other,doc,chore
config_file: .github/tag-changelog-config.js

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.number }}
release_name: ${{ steps.version.outputs.number }}
body: ${{ steps.changelog.outputs.changes }}
draft: false
prerelease: false

- name: Upload JAR to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/${{ steps.get_name.outputs.name }}.jar
asset_name: ${{ steps.get_name.outputs.name }}.jar
asset_content_type: application/java-archive
26 changes: 13 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: '3.8'

volumes:
postgres_data:
driver: local
# volumes:
# postgres_data:
# driver: local

services:
postgres:
Expand Down Expand Up @@ -46,12 +46,12 @@ services:
- 9080:8080
- 8443:8443
volumes:
- $PWD/target/keycloak-openfga-event-publisher-1.0.0-jar-with-dependencies.jar:/opt/keycloak/providers/keycloak-openfga-event-publisher-1.0.0.jar
- $PWD/target/keycloak-openfga-event-publisher.jar:/opt/keycloak/providers/keycloak-openfga-event-publisher.jar
depends_on:
- postgres
# condition: service_completed_successfully
# openfga:
# condition: service_completed_successfully
postgres:
condition: service_completed_successfully
openfga:
condition: service_completed_successfully
networks:
default:
aliases:
Expand Down Expand Up @@ -98,11 +98,11 @@ services:
- OPENFGA_DATASTORE_ENGINE=postgres
- OPENFGA_DATASTORE_URI=postgres://postgres:password@postgres-openfga:5432/postgres?sslmode=disable
- OPENFGA_DATASTORE_MAX_OPEN_CONNS=100
# healthcheck:
# interval: 5s
# test: ["CMD", "curl", "-f", "http://localhost:8080/healthz"]
# timeout: 5s
# retries: 5
healthcheck:
test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=openfga:8081"]
interval: 3s
timeout: 30s
retries: 3
networks:
- default
ports:
Expand Down
63 changes: 44 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.twogentity.keycloak</groupId>
<artifactId>keycloak-openfga-event-publisher</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<keycloak.version>19.0.0</keycloak.version>
<kafka.version>3.3.1</kafka.version>
<jackson.version>2.15.2</jackson.version>
<jackson.databind.version>2.15.2</jackson.databind.version>
<junit.version>5.8.1</junit.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-parent</artifactId>
<version>${keycloak.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-parent</artifactId>
<version>${keycloak.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -31,8 +32,8 @@
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>${keycloak.version}</version>
</dependency>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
Expand All @@ -51,6 +52,7 @@
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.5.0.Final</version>
<scope>provided</scope>
</dependency>

Expand All @@ -60,6 +62,24 @@
<version>0.1.0</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.databind.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -69,23 +89,28 @@
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>org.openapitools:jackson-databind-nullable</include>
<include>dev.openfga:openfga-sdk</include>
</includes>
</artifactSet>
</configuration>
</plugin>
</plugins>
</build>
Expand Down

0 comments on commit a6bfa5b

Please sign in to comment.