From cd2451d58b5c6e167415117dc2a72a7f28878588 Mon Sep 17 00:00:00 2001 From: Peter Zaoral Date: Fri, 31 May 2024 19:21:19 +0200 Subject: [PATCH] Remove Oracle JDBC driver out of the box (#29895) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #29491 Co-authored-by: Václav Muzikář Co-authored-by: Martin Bartoš Signed-off-by: Peter Zaoral --- .../topics/changes/changes-25_0_0.adoc | 5 +++ docs/guides/server/db.adoc | 8 ++-- quarkus/runtime/pom.xml | 24 +++++------- .../it/cli/dist/BuildCommandDistTest.java | 14 ++----- .../it/storage/database/OracleTest.java | 16 ++++++++ .../it/utils/RawKeycloakDistribution.java | 2 - .../servers/auth-server/quarkus/pom.xml | 39 ++++++++++++------- 7 files changed, 63 insertions(+), 45 deletions(-) diff --git a/docs/documentation/upgrading/topics/changes/changes-25_0_0.adoc b/docs/documentation/upgrading/topics/changes/changes-25_0_0.adoc index 720838cf92..70209777a1 100644 --- a/docs/documentation/upgrading/topics/changes/changes-25_0_0.adoc +++ b/docs/documentation/upgrading/topics/changes/changes-25_0_0.adoc @@ -433,3 +433,8 @@ If the session is using the remember me feature, the idle timeout and max lifesp {project_name} now requires a {jdgserver_name} server version of at least 15.0.0 for external {jdgserver_name} deployments. An external {jdgserver_name} deployment is supported for multi-site setups as outlined in the HA guide. + += Oracle Database driver not part of the distribution + +The Oracle Database JDBC driver is no longer part of the Keycloak distribution. +If you wish to use Oracle DB, you must manually install a version of the Oracle Driver that is compatible with your specific environment. Instructions for this process can be found in the https://www.keycloak.org/server/db[Configuring the database] {section}. diff --git a/docs/guides/server/db.adoc b/docs/guides/server/db.adoc index 074851c19c..060b2e6c91 100644 --- a/docs/guides/server/db.adoc +++ b/docs/guides/server/db.adoc @@ -30,13 +30,11 @@ The server has built-in support for different databases. You can query the avail By default, the server uses the `dev-file` database. This is the default database that the server will use to persist data and only exists for development use-cases. The `dev-file` database is not suitable for production use-cases, and must be replaced before deploying to production. -<@profile.ifProduct> - == Installing a database driver -Database drivers are shipped as part of {project_name} except for the Oracle Database and Microsoft SQL Server drivers which need to be installed separately. +Database drivers are shipped as part of {project_name} except for the Oracle Database<@profile.ifProduct> and Microsoft SQL Server drivers. -Install the necessary driver if you want to connect to one of these databases or skip this section if you want to connect to a different database for which the database driver is already included. +Install the necessary missing driver manually if you want to connect to one of these databases or skip this section if you want to connect to a different database for which the database driver is already included. === Installing the Oracle Database driver @@ -74,6 +72,8 @@ See the <@links.server id="containers" /> {section} for details on how to build Then continue configuring the database as described in the next section. +<@profile.ifProduct> + === Installing the Microsoft SQL Server driver To install the Microsoft SQL Server driver for {project_name}: diff --git a/quarkus/runtime/pom.xml b/quarkus/runtime/pom.xml index ea65f4aa43..6848136688 100644 --- a/quarkus/runtime/pom.xml +++ b/quarkus/runtime/pom.xml @@ -78,6 +78,16 @@ io.quarkus quarkus-jdbc-oracle + + + com.oracle.database.jdbc + ojdbc11 + + + com.oracle.database.nls + orai18n + + io.quarkus @@ -665,20 +675,6 @@ - - io.quarkus - quarkus-jdbc-oracle - - - com.oracle.database.jdbc - ojdbc11 - - - com.oracle.database.nls - orai18n - - - io.quarkus quarkus-jdbc-mssql diff --git a/quarkus/tests/integration/src/test/java/org/keycloak/it/cli/dist/BuildCommandDistTest.java b/quarkus/tests/integration/src/test/java/org/keycloak/it/cli/dist/BuildCommandDistTest.java index 7b5b4e021e..ac9b9b6858 100644 --- a/quarkus/tests/integration/src/test/java/org/keycloak/it/cli/dist/BuildCommandDistTest.java +++ b/quarkus/tests/integration/src/test/java/org/keycloak/it/cli/dist/BuildCommandDistTest.java @@ -103,16 +103,8 @@ class BuildCommandDistTest { void missingOracleJdbcDriver(LaunchResult result) { CLIResult cliResult = (CLIResult) result; - String dbDriver = Database.getDriver("oracle", true).orElse(""); - String errorMessage = String.format("ERROR: Unable to find the JDBC driver (%s). You need to install it.", dbDriver); - - boolean isProduct = System.getProperty("product") != null; - if (isProduct) { - cliResult.assertError(errorMessage); - cliResult.assertNoBuild(); - } else { - cliResult.assertNoMessage(errorMessage); - cliResult.assertBuild(); - } + String dbDriver = Database.getDriver("oracle", false).orElse(""); + cliResult.assertError(String.format("ERROR: Unable to find the JDBC driver (%s). You need to install it.", dbDriver)); + cliResult.assertNoBuild(); } } diff --git a/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/database/OracleTest.java b/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/database/OracleTest.java index 032e0df8a2..0c109f5266 100644 --- a/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/database/OracleTest.java +++ b/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/database/OracleTest.java @@ -17,12 +17,18 @@ package org.keycloak.it.storage.database; +import org.keycloak.it.junit5.extension.BeforeStartDistribution; import org.keycloak.it.junit5.extension.CLIResult; import org.keycloak.it.junit5.extension.CLITest; import org.keycloak.it.junit5.extension.WithDatabase; +import org.keycloak.it.utils.KeycloakDistribution; +import org.keycloak.it.utils.RawKeycloakDistribution; + +import java.util.function.Consumer; @CLITest @WithDatabase(alias = "oracle") +@BeforeStartDistribution(OracleTest.CopyOracleJdbcDriver.class) public class OracleTest extends BasicDatabaseTest { @Override @@ -34,4 +40,14 @@ public class OracleTest extends BasicDatabaseTest { protected void assertWrongPassword(CLIResult cliResult) { cliResult.assertMessage("ORA-01017: invalid username/password; logon denied"); } + + public static class CopyOracleJdbcDriver implements Consumer { + + @Override + public void accept(KeycloakDistribution distribution) { + RawKeycloakDistribution rawDist = distribution.unwrap(RawKeycloakDistribution.class); + rawDist.copyProvider("com.oracle.database.jdbc", "ojdbc11"); + rawDist.copyProvider("com.oracle.database.nls", "orai18n"); + } + } } diff --git a/quarkus/tests/junit5/src/main/java/org/keycloak/it/utils/RawKeycloakDistribution.java b/quarkus/tests/junit5/src/main/java/org/keycloak/it/utils/RawKeycloakDistribution.java index 8a988fa1b3..6f984c35d5 100644 --- a/quarkus/tests/junit5/src/main/java/org/keycloak/it/utils/RawKeycloakDistribution.java +++ b/quarkus/tests/junit5/src/main/java/org/keycloak/it/utils/RawKeycloakDistribution.java @@ -460,8 +460,6 @@ public final class RawKeycloakDistribution implements KeycloakDistribution { if (System.getProperty("product") != null) { // JDBC drivers might be excluded if running as a product build copyProvider(dPath, "com.microsoft.sqlserver", "mssql-jdbc"); - copyProvider(dPath, "com.oracle.database.jdbc", "ojdbc11"); - copyProvider(dPath, "com.oracle.database.nls", "orai18n"); } } diff --git a/testsuite/integration-arquillian/servers/auth-server/quarkus/pom.xml b/testsuite/integration-arquillian/servers/auth-server/quarkus/pom.xml index 626eedf1f6..fc10679b00 100644 --- a/testsuite/integration-arquillian/servers/auth-server/quarkus/pom.xml +++ b/testsuite/integration-arquillian/servers/auth-server/quarkus/pom.xml @@ -191,6 +191,31 @@ + + includeOracleJdbcDriver + generate-resources + + copy + + + + + com.oracle.database.jdbc + ojdbc11 + ${oracle-jdbc.version} + jar + ${auth.server.home}/providers + + + com.oracle.database.nls + orai18n + ${oracle-jdbc.version} + jar + ${auth.server.home}/providers + + + + copy-testsuite-providers generate-resources @@ -363,20 +388,6 @@ - - com.oracle.database.jdbc - ojdbc11 - ${oracle-jdbc.version} - jar - ${auth.server.home}/providers - - - com.oracle.database.nls - orai18n - ${oracle-jdbc.version} - jar - ${auth.server.home}/providers - com.microsoft.sqlserver mssql-jdbc