Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ protected void prepareOperationalInfo(Connection connection) {
try {
operationalInfo = new LinkedHashMap<>();
DatabaseMetaData md = connection.getMetaData();
operationalInfo.put("databaseUrl", md.getURL());
operationalInfo.put("databaseUser", md.getUserName());
operationalInfo.put("databaseProduct", md.getDatabaseProductName() + " " + md.getDatabaseProductVersion());
operationalInfo.put("databaseDriver", md.getDriverName() + " " + md.getDriverVersion());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ private void createOperationalInfo(Connection connection) {
try {
operationalInfo = new LinkedHashMap<>();
DatabaseMetaData md = connection.getMetaData();
operationalInfo.put("databaseUrl", md.getURL());
operationalInfo.put("databaseUser", md.getUserName());
operationalInfo.put("databaseProduct", md.getDatabaseProductName() + " " + md.getDatabaseProductVersion());
operationalInfo.put("databaseDriver", md.getDriverName() + " " + md.getDriverVersion());
operationalInfo.put("migrationTimeout", getMigrationTransactionTimeout() + " seconds");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@



import java.util.Objects;

import jakarta.ws.rs.ForbiddenException;

import org.keycloak.models.AdminRoles;
import org.keycloak.representations.info.ServerInfoRepresentation;
import org.keycloak.representations.info.SpiInfoRepresentation;
import org.keycloak.testframework.annotations.InjectRealm;
import org.keycloak.testframework.annotations.KeycloakIntegrationTest;
import org.keycloak.testframework.realm.ManagedRealm;
Expand Down Expand Up @@ -85,6 +88,25 @@ public void testServerInfo() throws Exception {
Assert.assertNull(serverInfo.getSystemInfo().getServerTime());
Assert.assertNull(serverInfo.getCpuInfo());
Assert.assertNull(serverInfo.getMemoryInfo());

// databaseUrl and databaseUser are never exposed in server info
assertDatabaseConnectionInfoNotExposed(clients.get("master-admin").serverInfo().getInfo());
assertDatabaseConnectionInfoNotExposed(clients.get("master-admin-" + AdminRoles.MANAGE_REALM).serverInfo().getInfo());
}

private void assertDatabaseConnectionInfoNotExposed(ServerInfoRepresentation serverInfo) {
SpiInfoRepresentation jpa = serverInfo.getProviders().get("connectionsJpa");
Assert.assertNotNull("connectionsJpa SPI should be present", jpa);
boolean foundDatabaseUrl = jpa.getProviders().values().stream()
.map(p -> p.getOperationalInfo())
.filter(Objects::nonNull)
.anyMatch(info -> info.containsKey("databaseUrl"));
Assert.assertFalse("connectionsJpa operationalInfo should not contain databaseUrl", foundDatabaseUrl);
boolean foundDatabaseUser = jpa.getProviders().values().stream()
.map(p -> p.getOperationalInfo())
.filter(Objects::nonNull)
.anyMatch(info -> info.containsKey("databaseUser"));
Assert.assertFalse("connectionsJpa operationalInfo should not contain databaseUser", foundDatabaseUser);
}

protected static class PermissionsTestRealm extends PermissionsTestRealmConfig1 {
Expand Down
Loading