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

Update to Keycloak 22.0.0 #899

Closed
wants to merge 2 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=21.1.1
KEYCLOAK_VERSION=22.0.0
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- KEYCLOAK_VERSION: 19.0.3
- KEYCLOAK_VERSION: 20.0.5
- KEYCLOAK_VERSION: 21.1.1
- KEYCLOAK_VERSION: 22.0.0
steps:
- uses: actions/checkout@v3
with:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
- Refactored support for user profile updates

## [5.7.0]
- Added support for Keycloak 22
- Update to Spring Boot 2.7.13
- Adapt packages for Jakarta EE migration

## [5.6.1] - 2023-03-05

## [5.6.0] - 2023-03-05
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=21.1.1
ARG KEYCLOAK_VERSION=22.0.0
ARG MAVEN_CLI_OPTS="-ntp -B"

COPY .mvn .mvn
Expand Down
69 changes: 64 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.12</version>
<version>2.7.13</version>
<relativePath />
</parent>

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>21.1.1</keycloak.version>
<keycloak.version>22.0.0</keycloak.version>

<checkstyle-plugin.version>3.2.0</checkstyle-plugin.version>
<checkstyle.version>10.0</checkstyle.version>
Expand All @@ -84,7 +84,13 @@
<pmd-plugin.version>3.21.0</pmd-plugin.version>
<pmd.version>6.55.0</pmd.version>
<reproducible-build-maven-plugin.version>0.15</reproducible-build-maven-plugin.version>
<resteasy.version>5.0.4.Final</resteasy.version>
<resteasy.version>6.2.4.Final</resteasy.version>
<snakeyaml.version>2.0</snakeyaml.version>
<jakarta.ws.rs-api.version>3.1.0</jakarta.ws.rs-api.version>
<jakarta.activation.version>2.1.2</jakarta.activation.version>
<jakarta.annotation.version>2.1.1</jakarta.annotation.version>
<jakarta.mail.version>2.1.2</jakarta.mail.version>
<spring-security-crypto.version>5.8.4</spring-security-crypto.version>
<spotbugs-plugin.version>4.7.3.5</spotbugs-plugin.version>
<spotbugs.version>4.7.3</spotbugs.version>
<testcontainers.version>1.18.3</testcontainers.version>
Expand Down Expand Up @@ -160,6 +166,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
Copy link
Contributor

@thomasdarimont thomasdarimont Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to have the different dependencies guarded with a profile.

Perhaps have a default profile that uses the new jakarta ee deps and an "javax" profile, which uses the old dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An interesting thought, normally I do write services that follow one simple ruleset which perfectly fits the surrounding services. Frameworks with multiple supported versions are completely new for me. ;)

<exclusion>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -176,7 +188,7 @@
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>5.8.3</version>
<version>${spring-security-crypto.version}</version>
</dependency>

<dependency>
Expand All @@ -193,7 +205,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.0</version>
<version>${snakeyaml.version}</version>
</dependency>

<dependency>
Expand All @@ -204,6 +216,53 @@
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
</exclusion>

<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>${jakarta.ws.rs-api.version}</version>
</dependency>

<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>${jakarta.activation.version}</version>
</dependency>

<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${jakarta.annotation.version}</version>
</dependency>

<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<version>${jakarta.mail.version}</version>
<exclusions>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import de.adorsys.keycloak.config.exception.KeycloakProviderException;
import de.adorsys.keycloak.config.properties.KeycloakConfigProperties;
import de.adorsys.keycloak.config.util.ResteasyUtil;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.Response;
import net.jodah.failsafe.Failsafe;
import net.jodah.failsafe.RetryPolicy;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
Expand All @@ -40,10 +44,6 @@
import java.net.URL;
import java.text.MessageFormat;
import java.time.Duration;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;

/**
* This class exists because we need to create a single keycloak instance or to close the keycloak before using a new one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import de.adorsys.keycloak.config.exception.ImportProcessingException;
import de.adorsys.keycloak.config.exception.KeycloakRepositoryException;
import de.adorsys.keycloak.config.util.ResponseUtil;
import jakarta.ws.rs.ClientErrorException;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.AuthenticationManagementResource;
import org.keycloak.admin.client.resource.RealmResource;
Expand All @@ -38,10 +42,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import javax.ws.rs.ClientErrorException;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

@Service
public class AuthenticationFlowRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import de.adorsys.keycloak.config.exception.ImportProcessingException;
import de.adorsys.keycloak.config.exception.KeycloakRepositoryException;
import de.adorsys.keycloak.config.util.ResponseUtil;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.ClientResource;
import org.keycloak.admin.client.resource.ClientsResource;
Expand All @@ -42,8 +44,6 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

@Service
public class ClientRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import de.adorsys.keycloak.config.exception.ImportProcessingException;
import de.adorsys.keycloak.config.util.ResponseUtil;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.ClientScopeResource;
import org.keycloak.admin.client.resource.ClientScopesResource;
Expand All @@ -36,8 +38,6 @@
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

@Service
public class ClientScopeRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import de.adorsys.keycloak.config.exception.ImportProcessingException;
import de.adorsys.keycloak.config.exception.KeycloakRepositoryException;
import de.adorsys.keycloak.config.util.ResponseUtil;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.ComponentsResource;
import org.keycloak.admin.client.resource.RealmResource;
Expand All @@ -34,8 +36,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

@Service
public class ComponentRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import de.adorsys.keycloak.config.exception.ImportProcessingException;
import de.adorsys.keycloak.config.exception.KeycloakRepositoryException;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.AuthenticationManagementResource;
import org.keycloak.representations.idm.AuthenticationExecutionExportRepresentation;
Expand All @@ -37,8 +39,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

@Service
public class ExecutionFlowRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package de.adorsys.keycloak.config.repository;

import de.adorsys.keycloak.config.exception.ImportProcessingException;
import jakarta.ws.rs.core.Response;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.GroupResource;
import org.keycloak.admin.client.resource.GroupsResource;
Expand All @@ -39,7 +40,6 @@
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.ws.rs.core.Response;

@Service
public class GroupRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package de.adorsys.keycloak.config.repository;

import jakarta.ws.rs.core.Response;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.IdentityProviderResource;
import org.keycloak.admin.client.resource.IdentityProvidersResource;
Expand All @@ -32,7 +33,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import javax.ws.rs.core.Response;

@Service
public class IdentityProviderMapperRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import de.adorsys.keycloak.config.provider.KeycloakProvider;
import de.adorsys.keycloak.config.resource.ManagementPermissions;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.core.Response;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.IdentityProviderResource;
import org.keycloak.admin.client.resource.IdentityProvidersResource;
Expand All @@ -32,8 +34,6 @@

import java.util.List;
import java.util.Optional;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.Response;

@Service
public class IdentityProviderRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
import de.adorsys.keycloak.config.exception.KeycloakRepositoryException;
import de.adorsys.keycloak.config.provider.KeycloakProvider;
import de.adorsys.keycloak.config.util.ResponseUtil;
import jakarta.ws.rs.WebApplicationException;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.RealmsResource;
import org.keycloak.representations.idm.RealmRepresentation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.ws.rs.WebApplicationException;

@Service
public class RealmRepository {
private final KeycloakProvider keycloakProvider;
Expand All @@ -44,7 +43,7 @@ public RealmRepository(KeycloakProvider keycloakProvider) {
public boolean exists(String realmName) {
try {
get(realmName);
} catch (javax.ws.rs.NotFoundException e) {
} catch (jakarta.ws.rs.NotFoundException e) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public RequiredActionProviderRepresentation getByAlias(String realmName, String
try {
AuthenticationManagementResource flows = authenticationFlowRepository.getFlowResources(realmName);
return flows.getRequiredAction(requiredActionAlias);
} catch (javax.ws.rs.NotFoundException e) {
} catch (jakarta.ws.rs.NotFoundException e) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Optional<RoleRepresentation> searchRealmRole(String realmName, String nam

try {
maybeRole = Optional.of(roleResource.toRepresentation());
} catch (javax.ws.rs.NotFoundException e) {
} catch (jakarta.ws.rs.NotFoundException e) {
maybeRole = Optional.empty();
}

Expand Down Expand Up @@ -136,7 +136,7 @@ public List<RoleRepresentation> getClientRolesByName(String realmName, String cl
for (String roleName : roleNames) {
try {
roles.add(clientResource.roles().get(roleName).toRepresentation());
} catch (javax.ws.rs.NotFoundException e) {
} catch (jakarta.ws.rs.NotFoundException e) {
throw new KeycloakRepositoryException(
"Cannot find client role '%s' for client '%s' within realm '%s'",
roleName, clientId, realmName
Expand Down Expand Up @@ -179,7 +179,7 @@ public List<RoleRepresentation> searchRealmRoles(String realmName, List<String>
RoleRepresentation role = realmResource.roles().get(roleName).toRepresentation();

roles.add(role);
} catch (javax.ws.rs.NotFoundException e) {
} catch (jakarta.ws.rs.NotFoundException e) {
throw new ImportProcessingException(
String.format("Could not find role '%s' in realm '%s'!", roleName, realmName)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import de.adorsys.keycloak.config.exception.KeycloakRepositoryException;
import de.adorsys.keycloak.config.util.JsonUtil;
import jakarta.ws.rs.core.Response;
import org.keycloak.admin.client.resource.UserProfileResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -30,7 +31,6 @@
import org.springframework.util.StringUtils;

import java.util.Optional;
import javax.ws.rs.core.Response;

@Component
public class UserProfileRepository {
Expand Down
Loading
Loading