Skip to content

Commit

Permalink
port to 25 (#60)
Browse files Browse the repository at this point in the history
* port to 25

* update to jdk 21 dep

* removed build step from release yaml. pom update to 0.76 orgs version.
  • Loading branch information
xgp authored Jun 19, 2024
1 parent a8856ab commit 253c014
Show file tree
Hide file tree
Showing 9 changed files with 501 additions and 63 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Build and Test
uses: qcastel/github-actions-maven-cmd@master
with:
maven-args: "clean install -Dmaven.test.skip=true -Ddockerfile.skip -DdockerCompose.skip -Djib.skip"

- name: Release
uses: qcastel/github-actions-maven-release@master
with:
Expand Down
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
</licenses>

<properties>
<java.version>17</java.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.java.package>io.phasetwo.keycloak.events</main.java.package>
<junit.version>5.8.2</junit.version>
<keycloak.version>24.0.3</keycloak.version>
<keycloak.version>25.0.0</keycloak.version>
<lombok.version>1.18.32</lombok.version>
<auto-service.version>1.1.1</auto-service.version>
<ossrh.url>https://s01.oss.sonatype.org</ossrh.url>
Expand Down Expand Up @@ -123,6 +123,11 @@
</systemPropertyVariables>
</configuration>
</plugin>
<plugin> <!-- pretty up the code using google java standards `mvn fmt:format` -->
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.23</version>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -262,7 +267,7 @@
<dependency> <!-- so we can test webhooks for org methods -->
<groupId>io.phasetwo.keycloak</groupId>
<artifactId>keycloak-orgs</artifactId>
<version>[0.61,)</version>
<version>[0.76,)</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import lombok.extern.jbosslog.JBossLog;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.keycloak.broker.provider.util.SimpleHttp;
import org.keycloak.models.KeycloakSession;
import org.keycloak.util.JsonSerialization;
Expand Down Expand Up @@ -71,9 +69,8 @@ protected void send(
SenderTask task, String targetUri, Optional<String> sharedSecret, Optional<String> algorithm)
throws SenderException, IOException {
log.debugf("attempting send to %s", targetUri);
try (CloseableHttpClient http = HttpClients.createDefault()) {
// SimpleHttp request = SimpleHttp.doPost(targetUri, session).json(task.getEvent());
SimpleHttp request = SimpleHttp.doPost(targetUri, http).json(task.getEvent());
try {
SimpleHttp request = SimpleHttp.doPost(targetUri, session).json(task.getEvent());
sharedSecret.ifPresent(
secret ->
request.header(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import jakarta.ws.rs.core.Response;
import lombok.extern.jbosslog.JBossLog;
import org.keycloak.http.HttpRequest;
import org.keycloak.http.HttpResponse;
import org.keycloak.models.KeycloakSession;
import org.keycloak.services.cors.Cors;
import org.keycloak.services.resources.admin.AdminAuth;
Expand All @@ -28,17 +27,15 @@ public CorsResource(KeycloakSession session, HttpRequest request) {
@Path("{any:.*}")
public Response preflight() {
log.debug("CORS OPTIONS preflight request");
return Cors.add(request, Response.ok()).auth().allowedMethods(METHODS).preflight().build();
return Cors.builder().auth().allowedMethods(METHODS).preflight().add(Response.ok());
}

public static void setupCors(KeycloakSession session, AdminAuth auth) {
HttpRequest request = session.getContext().getHttpRequest();
HttpResponse response = session.getContext().getHttpResponse();
Cors.add(request)
Cors.builder()
.allowedOrigins(auth.getToken())
.allowedMethods(METHODS)
.exposedHeaders("Location")
.auth()
.build(response);
.add();
}
}
5 changes: 2 additions & 3 deletions src/test/java/io/phasetwo/keycloak/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.broker.provider.util.SimpleHttp;
import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
import org.keycloak.representations.idm.UserRepresentation;

Expand Down Expand Up @@ -75,8 +74,8 @@ public static String createWebhook(
rep.setEventTypes(types);
}

SimpleHttp.Response response =
SimpleHttp.doPost(baseUrl, httpClient)
LegacySimpleHttp.Response response =
LegacySimpleHttp.doPost(baseUrl, httpClient)
.auth(keycloak.tokenManager().getAccessTokenString())
.json(rep)
.asResponse();
Expand Down
Loading

0 comments on commit 253c014

Please sign in to comment.