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

Add Keycloak 24 #997

Closed
wants to merge 4 commits into from
Closed
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=23.0.1
KEYCLOAK_VERSION=24.0.1
8 changes: 6 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ jobs:
- KEYCLOAK_VERSION: 20.0.5
- KEYCLOAK_VERSION: 21.1.1
- KEYCLOAK_VERSION: 22.0.4
- KEYCLOAK_VERSION: 23.0.1
- KEYCLOAK_VERSION: 23.0.7
- KEYCLOAK_VERSION: 24.0.1
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -61,8 +62,11 @@ jobs:
echo "JAVAX_PROFILE=-Ppre-keycloak22" >> $GITHUB_ENV
echo "ADJUSTED_RESTEASY_VERSION=-Dresteasy.version=4.7.7.Final" >> $GITHUB_ENV

- name: Output maven dependency tree
run: ./mvnw dependency:tree

- name: Build & Test
run: ./mvnw ${MAVEN_CLI_OPTS} -Dkeycloak.version=${{ matrix.env.KEYCLOAK_VERSION }} ${ADJUSTED_RESTEASY_VERSION} clean verify -Pcoverage ${JAVAX_PROFILE}
run: ./mvnw ${MAVEN_CLI_OPTS} -Dkeycloak.version=${{ matrix.env.KEYCLOAK_VERSION }} ${ADJUSTED_RESTEASY_VERSION} clean verify -Pcoverage ${JAVAX_PROFILE} -X

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Updated CI to use Keycloak 23.0.4
- Changed briefRepresentation from false to true (mistakenly considered full: [#25096](https://github.com/keycloak/keycloak/issues/25096))
- Using getGroupByPath again after being fixed ([#25111](https://github.com/keycloak/keycloak/issues/25111))

## [5.10.0] - 2023-12-12
- Updated CI to use Keycloak 23.0.1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM ${BUILDER_IMAGE} AS BUILDER

WORKDIR /app/

ARG KEYCLOAK_VERSION=23.0.1
ARG KEYCLOAK_VERSION=24.0.1
ARG MAVEN_CLI_OPTS="-ntp -B"

COPY .mvn .mvn
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Additionally, the tag `maven` contains the source code and compile keycloak-conf
Keycloak versions, that not official supported., e.g.:

```bash
docker run --rm -ti -v $PWD:/config/ -eKEYCLOAK_VERSION=23.0.1 -eMAVEN_CLI_OPTS="-B -ntp -q" adorsys/keycloak-config-cli:edge-build
docker run --rm -ti -v $PWD:/config/ -eKEYCLOAK_VERSION=24.0.1 -eMAVEN_CLI_OPTS="-B -ntp -q" adorsys/keycloak-config-cli:edge-build
```

### Docker run
Expand Down
42 changes: 3 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<keycloak.version>23.0.1</keycloak.version>
<keycloak.version>24.0.1</keycloak.version>

<checkstyle-plugin.version>3.2.0</checkstyle-plugin.version>
<checkstyle.version>10.0</checkstyle.version>
Expand Down Expand Up @@ -702,24 +702,6 @@
<id>pre-keycloak22</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-grouputil-with-legacy</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${project.basedir}/src/main/java/de/adorsys/keycloak/config/util/GroupUtil.java.legacy</sourceFile>
<destinationFile>${project.basedir}/src/main/java/de/adorsys/keycloak/config/util/GroupUtil.java</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
Expand Down Expand Up @@ -773,7 +755,7 @@ import org.keycloak.representations.userprofile.config.UPConfig;</token>
<value>userProfileResource.update(newUserProfileConfiguration);</value>
</replacement>
<replacement>
<token>return groupResource.getSubGroups\(null, null, true\);</token>
<token>return groupResource.getSubGroups\(null, null, false\);</token>
<value>return groupResource.toRepresentation().getSubGroups();</value>
</replacement>
</replacements>
Expand All @@ -786,24 +768,6 @@ import org.keycloak.representations.userprofile.config.UPConfig;</token>
<id>pre-keycloak23</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-grouputil-with-legacy</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${project.basedir}/src/main/java/de/adorsys/keycloak/config/util/GroupUtil.java.legacy</sourceFile>
<destinationFile>${project.basedir}/src/main/java/de/adorsys/keycloak/config/util/GroupUtil.java</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
Expand Down Expand Up @@ -853,7 +817,7 @@ import org.keycloak.representations.userprofile.config.UPConfig;</token>
<value>userProfileResource.update(newUserProfileConfiguration);</value>
</replacement>
<replacement>
<token>return groupResource.getSubGroups\(null, null, true\);</token>
<token>return groupResource.getSubGroups\(null, null, false\);</token>
<value>return groupResource.toRepresentation().getSubGroups();</value>
</replacement>
</replacements>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package de.adorsys.keycloak.config.repository;

import de.adorsys.keycloak.config.exception.ImportProcessingException;
import de.adorsys.keycloak.config.util.GroupUtil;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.GroupResource;
import org.keycloak.admin.client.resource.GroupsResource;
Expand Down Expand Up @@ -121,7 +120,7 @@ public GroupRepresentation getSubGroupByName(String realmName, String parentGrou

public List<GroupRepresentation> getSubGroups(String realmName, String parentGroupId) {
var groupResource = getResourceById(realmName, parentGroupId);
return groupResource.getSubGroups(null, null, true);
return groupResource.getSubGroups(null, null, false);
}

public void addRealmRoles(String realmName, String groupId, List<String> roleNames) {
Expand Down Expand Up @@ -211,7 +210,7 @@ public GroupRepresentation getGroupById(String realmName, String groupId) {
}

public GroupRepresentation getGroupByPath(String realmName, String groupPath) {
return GroupUtil.getGroupByPath(this, realmRepository, realmName, groupPath);
return realmRepository.getResource(realmName).getGroupByPath(groupPath);
}

public void enablePermission(String realmName, String id) {
Expand Down
86 changes: 0 additions & 86 deletions src/main/java/de/adorsys/keycloak/config/util/GroupUtil.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ abstract public class AbstractImportIT extends AbstractImportTest {
KEYCLOAK_CONTAINER.setCommand("start-dev");
command.add("start-dev");
command.add("--features");
command.add("admin-fine-grained-authz,declarative-user-profile,client-policies,client-secret-rotation");
if(VersionUtil.lt(KEYCLOAK_VERSION, "24")) {
command.add("admin-fine-grained-authz,declarative-user-profile,client-policies,client-secret-rotation");
} else {
command.add("admin-fine-grained-authz,client-policies,client-secret-rotation");
}
}

if (System.getProperties().getOrDefault("skipContainerStart", "false").equals("false")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1752,26 +1752,14 @@ private List<GroupRepresentation> getSubGroups(GroupRepresentation groupRepresen
}

private void assertThatGroupAttributesAreEmpty(Map<String, List<String>> attributes) {
if (VersionUtil.lt(KEYCLOAK_VERSION, "23")) {
assertThat("attributes is null", attributes, aMapWithSize(0));
} else {
assertThat("attributes is null", attributes, is(nullValue()));
}
assertThat("attributes is null", attributes, aMapWithSize(0));
}

private void assertThatGroupRealmRolesAreEmpty(List<String> realmRoles) {
if (VersionUtil.lt(KEYCLOAK_VERSION, "23")) {
assertThat("realm roles is null", realmRoles, hasSize(0));
} else {
assertThat("realm roles is null", realmRoles, is(nullValue()));
}
assertThat("realm roles is null", realmRoles, hasSize(0));
}

private void assertThatGroupClientRolesAreEmpty(Map<String, List<String>> clientRoles) {
if (VersionUtil.lt(KEYCLOAK_VERSION, "23")) {
assertThat("client roles not null", clientRoles, aMapWithSize(0));
} else {
assertThat("client roles not null", clientRoles, is(nullValue()));
}
assertThat("client roles not null", clientRoles, aMapWithSize(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.adorsys.keycloak.config.exception.ImportProcessingException;
import de.adorsys.keycloak.config.exception.InvalidImportException;
import de.adorsys.keycloak.config.exception.KeycloakRepositoryException;
import de.adorsys.keycloak.config.util.VersionUtil;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.keycloak.representations.idm.RealmRepresentation;
Expand Down Expand Up @@ -169,7 +170,12 @@ void shouldUpdateWebAuthnSettings() throws IOException {

assertThat(realm.getRealm(), is("simple"));
assertThat(realm.isEnabled(), is(true));
assertThat(realm.getWebAuthnPolicyPasswordlessUserVerificationRequirement(), is("required"));

// TODO: "webAuthnPolicyPasswordlessUserVerificationRequirement" is not set with Keycloak 24
// https://github.com/keycloak/keycloak/issues/27700
if(!VersionUtil.eqPrefix(KEYCLOAK_VERSION, "24")) {
assertThat(realm.getWebAuthnPolicyPasswordlessUserVerificationRequirement(), is("required"));
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public static List<GroupRepresentation> getSubGroups(

return realmResource.groups()
.group(groupRepresentation.getId())
.getSubGroups(null, null, true);
.getSubGroups(null, null, false);
}
}
Loading
Loading