Remove Oracle JDBC driver out of the box (#29895)

Closes: #29491

Co-authored-by: Václav Muzikář <vaclav@muzikari.cz>
Co-authored-by: Martin Bartoš <mabartos@redhat.com>
Signed-off-by: Peter Zaoral <pzaoral@redhat.com>
This commit is contained in:
Peter Zaoral 2024-05-31 19:21:19 +02:00 committed by GitHub
parent 6ee4d3259f
commit cd2451d58b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 63 additions and 45 deletions

View file

@ -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}.

View file

@ -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</@profile.ifProduct>.
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}:

View file

@ -78,6 +78,16 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-oracle</artifactId>
<exclusions>
<exclusion>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
</exclusion>
<exclusion>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
@ -665,20 +675,6 @@
</property>
</activation>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-oracle</artifactId>
<exclusions>
<exclusion>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
</exclusion>
<exclusion>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mssql</artifactId>

View file

@ -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();
}
}

View file

@ -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<KeycloakDistribution> {
@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");
}
}
}

View file

@ -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");
}
}

View file

@ -191,6 +191,31 @@
</artifactItems>
</configuration>
</execution>
<execution>
<id>includeOracleJdbcDriver</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>${oracle-jdbc.version}</version>
<type>jar</type>
<outputDirectory>${auth.server.home}/providers</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
<version>${oracle-jdbc.version}</version>
<type>jar</type>
<outputDirectory>${auth.server.home}/providers</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>copy-testsuite-providers</id>
<phase>generate-resources</phase>
@ -363,20 +388,6 @@
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>${oracle-jdbc.version}</version>
<type>jar</type>
<outputDirectory>${auth.server.home}/providers</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
<version>${oracle-jdbc.version}</version>
<type>jar</type>
<outputDirectory>${auth.server.home}/providers</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>