Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keycloak 26.0.0 #1162

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Used in docker-compose
# shellcheck disable=SC2034
KEYCLOAK_VERSION=25.0.1
KEYCLOAK_VERSION=26.0.0
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- KEYCLOAK_VERSION: 23.0.7
- KEYCLOAK_VERSION: 24.0.5
- KEYCLOAK_VERSION: 25.0.1
- KEYCLOAK_VERSION: 26.0.0
steps:
- uses: actions/[email protected]
with:
Expand All @@ -55,6 +56,11 @@ jobs:
key: ${{ runner.os }}-maven-${{ matrix.env.KEYCLOAK_VERSION }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-${{ matrix.env.KEYCLOAK_VERSION }}

- name: Adapt sources for Keycloak versions < 26.0.0
if: ${{ matrix.env.KEYCLOAK_VERSION < '26.0.0' }}
run: |
echo "COMPATIBILITY_PROFILE=-Ppre-keycloak26" >> $GITHUB_ENV

- name: Adapt sources for Keycloak versions < 23.0.0
if: ${{ matrix.env.KEYCLOAK_VERSION < '23.0.0' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
ARG BUILDER_IMAGE=eclipse-temurin:21-jdk
ARG RUNTIME_IMAGE=eclipse-temurin:21-jre

FROM ${BUILDER_IMAGE} AS BUILDER

Check warning on line 5 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (23.0.7)

Stage names should be lowercase

StageNameCasing: Stage name 'BUILDER' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 5 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (24.0.5)

Stage names should be lowercase

StageNameCasing: Stage name 'BUILDER' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 5 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (25.0.1)

Stage names should be lowercase

StageNameCasing: Stage name 'BUILDER' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

WORKDIR /app/

ARG KEYCLOAK_VERSION=25.0.1
ARG KEYCLOAK_VERSION=26.0.0
ARG MAVEN_CLI_OPTS="-ntp -B"

COPY .mvn .mvn
Expand All @@ -27,7 +27,7 @@
ENV JAVA_OPTS="" KEYCLOAK_SSL_VERIFY=true IMPORT_FILES_LOCATIONS=file:/config/*

# $0 represents the first CLI arg which is not inside $@
ENTRYPOINT exec java $JAVA_OPTS -jar /app/keycloak-config-cli.jar $0 $@

Check warning on line 30 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (23.0.7)

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

Check warning on line 30 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (24.0.5)

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

Check warning on line 30 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (25.0.1)

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

COPY --from=BUILDER /app/target/keycloak-config-cli.jar /app/keycloak-config-cli.jar

Expand Down
35 changes: 33 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<groupId>de.adorsys.keycloak</groupId>
<artifactId>keycloak-config-cli</artifactId>
<packaging>jar</packaging>
<version>6.1.7-SNAPSHOT</version>
<version>6.2.0-SNAPSHOT</version>

<name>keycloak-config-cli</name>
<url>https://github.com/adorsys/keycloak-config-cli</url>
Expand Down Expand Up @@ -59,7 +59,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<keycloak.version>25.0.1</keycloak.version>
<keycloak.version>26.0.0</keycloak.version>

<checkstyle-plugin.version>3.3.1</checkstyle-plugin.version>
<checkstyle.version>10.17.0</checkstyle.version>
Expand Down Expand Up @@ -177,6 +177,12 @@
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-authz-client</artifactId>
<version>${keycloak.version}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -779,6 +785,31 @@ import org.keycloak.representations.userprofile.config.UPConfig;</token>
</plugins>
</build>
</profile>
<profile>
<id>pre-keycloak26</id>
<build>
<plugins>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>replace-subgrouputil-with-legacy</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${project.basedir}/src/test/java/de/adorsys/keycloak/config/test/util/KeycloakMock.java.legacy</sourceFile>
<destinationFile>${project.basedir}/src/test/java/de/adorsys/keycloak/config/test/util/KeycloakMock.java</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>pre-keycloak23</id>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package de.adorsys.keycloak.config.test.util;

import org.apache.commons.lang3.StringUtils;
import org.keycloak.common.Version;
import org.keycloak.representations.AccessTokenResponse;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.info.ServerInfoRepresentation;
Expand Down Expand Up @@ -61,7 +62,7 @@ public static HttpResponse grantToken(HttpRequest request) throws JsonProcessing

public static HttpResponse serverInfo(HttpRequest request) throws JsonProcessingException {
ServerInfoRepresentation serverInfo = new ServerInfoRepresentation();
serverInfo.setSystemInfo(SystemInfoRepresentation.create(0));
serverInfo.setSystemInfo(SystemInfoRepresentation.create(0, Version.VERSION));

String json = new ObjectMapper().writeValueAsString(serverInfo);
return response()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*-
* ---license-start
* keycloak-config-cli
* ---
* Copyright (C) 2017 - 2021 adorsys GmbH & Co. KG @ https://adorsys.com
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*/

package de.adorsys.keycloak.config.test.util;

import org.apache.commons.lang3.StringUtils;
import org.keycloak.representations.AccessTokenResponse;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.info.ServerInfoRepresentation;
import org.keycloak.representations.info.SystemInfoRepresentation;
import org.mockserver.model.*;
import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Collections;

import static org.mockserver.model.HttpResponse.response;

public class KeycloakMock {
static final Headers cookieHeader = new Headers(
new Header("Set-Cookie", "key_expires=value; Expires=Sat, 09 Oct 2021 06:38:53 GMT; Path=/"),
new Header("Set-Cookie", "key=value")
);

public static HttpResponse grantToken(HttpRequest request) throws JsonProcessingException {
AccessTokenResponse token = new AccessTokenResponse();
String dummyToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";

token.setToken(dummyToken);
token.setRefreshToken(dummyToken);
token.setExpiresIn(60);
token.setRefreshExpiresIn(1800);
token.setTokenType("Bearer");
token.setNotBeforePolicy(0);
token.setSessionState("a04afd4e-d871-4357-b635-1754138ba341");
token.setScope("profile email");

String json = new ObjectMapper().writeValueAsString(token);

return response()
.withHeaders(cookieHeader)
.withBody(json, MediaType.APPLICATION_JSON);
}

public static HttpResponse serverInfo(HttpRequest request) throws JsonProcessingException {
ServerInfoRepresentation serverInfo = new ServerInfoRepresentation();
serverInfo.setSystemInfo(SystemInfoRepresentation.create(0));

String json = new ObjectMapper().writeValueAsString(serverInfo);
return response()
.withHeaders(cookieHeader)
.withBody(json, MediaType.APPLICATION_JSON);
}

public static HttpResponse realm(HttpRequest request) throws JsonProcessingException {
if (request.matches("PUT")) {
return noContent(request);
}

String realmName = StringUtils.substringAfterLast(request.getPath().toString(), "/");

RealmRepresentation realm = new RealmRepresentation();
realm.setRealm(realmName);
realm.setId("ef6addd5-7f2d-4781-ad89-99e0ed2e5eb7");
realm.setEventsEnabled(false);
realm.setAttributes(Collections.emptyMap());

String json = new ObjectMapper().writeValueAsString(realm);

return response()
.withHeaders(cookieHeader)
.withBody(json, MediaType.APPLICATION_JSON);
}

public static HttpResponse emptyList(HttpRequest request) {
return response()
.withHeaders(cookieHeader)
.withBody("[]", MediaType.APPLICATION_JSON);
}

public static HttpResponse noContent(HttpRequest request) {
return response()
.withHeaders(cookieHeader)
.withStatusCode(204);
}
}
Loading
Loading