Skip to content

Commit

Permalink
KEYCLOAK-8785 remove k_version endpoint (keycloak#6428)
Browse files Browse the repository at this point in the history
  • Loading branch information
pskopek authored and mposolda committed Nov 5, 2019
1 parent ecae2c5 commit d0386da
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ public boolean handleRequest() {
if (!resolveDeployment()) return true;
handlePushNotBefore();
return true;
} else if (requestUri.endsWith(AdapterConstants.K_VERSION)) {
handleVersion();
return true;
} else if (requestUri.endsWith(AdapterConstants.K_TEST_AVAILABLE)) {
if (!resolveDeployment()) return true;
handleTestAvailable();
Expand Down Expand Up @@ -246,25 +243,6 @@ protected boolean validateAction(AdminAction action) {
return true;
}

protected void handleVersion() {
try {
facade.getResponse().setStatus(200);
KeycloakDeployment deployment = deploymentContext.resolveDeployment(facade);
if (deployment.isCors()) {
String origin = facade.getRequest().getHeader(CorsHeaders.ORIGIN);
if (origin == null) {
log.debug("no origin header set in request");
} else {
facade.getResponse().setHeader(CorsHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, origin);
}
}
facade.getResponse().setHeader("Content-Type", "application/json");
JsonSerialization.writeValueToStream(facade.getResponse().getOutputStream(), VersionRepresentation.SINGLETON);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected void handleJwksRequest() {
try {
JSONWebKeySet jwks = new JSONWebKeySet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public class KeycloakCsrfRequestMatcher implements RequestMatcher {
AdapterConstants.K_LOGOUT,
AdapterConstants.K_PUSH_NOT_BEFORE,
AdapterConstants.K_QUERY_BEARER_TOKEN,
AdapterConstants.K_TEST_AVAILABLE,
AdapterConstants.K_VERSION
AdapterConstants.K_TEST_AVAILABLE
);

private Pattern allowedMethods = Pattern.compile("^(GET|HEAD|TRACE|OPTIONS)$");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,6 @@ public void testMatchesKeycloakTestAvailable() throws Exception {
assertFalse(matcher.matches(request));
}

@Test
public void testMatchesKeycloakVersion() throws Exception {

prepareRequest(HttpMethod.POST, ROOT_CONTEXT_PATH, AdapterConstants.K_VERSION);
assertFalse(matcher.matches(request));

prepareRequest(HttpMethod.POST, SUB_CONTEXT_PATH, AdapterConstants.K_VERSION);
assertFalse(matcher.matches(request));
}

private void prepareRequest(HttpMethod method, String contextPath, String uri) {
request.setMethod(method.name());
request.setContextPath(contextPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public interface AdapterConstants {

// URL endpoints
public static final String K_LOGOUT = "k_logout";
public static final String K_VERSION = "k_version";
public static final String K_PUSH_NOT_BEFORE = "k_push_not_before";
public static final String K_TEST_AVAILABLE = "k_test_available";
public static final String K_QUERY_BEARER_TOKEN = "k_query_bearer_token";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ module.controller('GlobalCtrl', function($scope, $http) {
$scope.roles = [];
$scope.serverInfo = [];
$scope.realm = [];
$scope.version = [];
$scope.reloadData = function() {
$http.get(getAppServerUrl("localhost-db-127.0.0.1.nip.io") + "/cors-database/products").success(function(data, status, headers, config) {
$scope.products = angular.fromJson(data);
Expand Down Expand Up @@ -108,12 +107,6 @@ module.controller('GlobalCtrl', function($scope, $http) {
});
};

$scope.loadVersion = function() {
$http.get(getAppServerUrl("localhost-db-127.0.0.1.nip.io") + "/cors-database/products/k_version").success(function(data) {
$scope.version = angular.fromJson(data);
});
};

$scope.logout = logout;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ public void angularCorsProductTest() {
jsDriverAngularCorsProductPage.navigateTo();
waitForPageToLoad();

jsDriverAngularCorsProductPage.loadVersion();
waitUntilElement(jsDriverAngularCorsProductPage.getOutput()).text().contains("Keycloak version: " + serverVersion);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,26 +669,6 @@ public void testBadUser() {
client.close();
}

@Test
public void testVersion() {
String serverVersion = adminClient.serverInfo().getInfo().getSystemInfo().getVersion();

assertNotNull(serverVersion);

Client client = ClientBuilder.newClient();

VersionRepresentation version2 = client.target(securePortal.toString()).path(AdapterConstants.K_VERSION).request().get(VersionRepresentation.class);
assertNotNull(version2);
assertNotNull(version2.getVersion());
assertNotNull(version2.getBuildTime());

log.info("version is " + version2.getVersion());
if (!suiteContext.isAdapterCompatTesting()) {
assertEquals(serverVersion, version2.getVersion());
}
client.close();
}

@Test
public void testAuthenticated() {
// test login to customer-portal which does a bearer request to customer-db
Expand Down

0 comments on commit d0386da

Please sign in to comment.