From fdc6fc59b8d417fcd9969b2ee345dcab9655d561 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Thu, 3 May 2018 12:14:14 -0400 Subject: [PATCH] KEYCLOAK-7304 --- .../models/utils/RepresentationToModel.java | 9 ++++++++- .../keycloak/testsuite/forms/FlowOverrideTest.java | 13 +++++++++++++ .../base/admin/resources/js/controllers/clients.js | 6 ++++++ .../admin/resources/partials/client-detail.html | 4 ++-- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/server-spi-private/src/main/java/org/keycloak/models/utils/RepresentationToModel.java b/server-spi-private/src/main/java/org/keycloak/models/utils/RepresentationToModel.java index 06545a234c..1deada1454 100755 --- a/server-spi-private/src/main/java/org/keycloak/models/utils/RepresentationToModel.java +++ b/server-spi-private/src/main/java/org/keycloak/models/utils/RepresentationToModel.java @@ -1096,6 +1096,10 @@ public class RepresentationToModel { if (entry.getValue() == null || entry.getValue().trim().equals("")) { continue; } else { + String flowId = entry.getValue(); + if (client.getRealm().getAuthenticationFlowById(flowId) == null) { + throw new RuntimeException("Unable to resolve auth flow binding override for: " + entry.getKey()); + } client.setAuthenticationFlowBindingOverride(entry.getKey(), entry.getValue()); } } @@ -1230,8 +1234,11 @@ public class RepresentationToModel { if (entry.getValue() == null || entry.getValue().trim().equals("")) { resource.removeAuthenticationFlowBindingOverride(entry.getKey()); } else { + String flowId = entry.getValue(); + if (resource.getRealm().getAuthenticationFlowById(flowId) == null) { + throw new RuntimeException("Unable to resolve auth flow binding override for: " + entry.getKey()); + } resource.setAuthenticationFlowBindingOverride(entry.getKey(), entry.getValue()); - } } } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/FlowOverrideTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/FlowOverrideTest.java index 33bb259011..80bff7be02 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/FlowOverrideTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/FlowOverrideTest.java @@ -348,6 +348,19 @@ public class FlowOverrideTest extends AbstractTestRealmKeycloakTest { clients.get(clientRep.getId()).update(clientRep); testWithClientBrowserOverride(); + query = clients.findByClientId(TEST_APP_FLOW); + clientRep = query.get(0); + clientRep.getAuthenticationFlowBindingOverrides().put(AuthenticationFlowBindings.BROWSER_BINDING, "bad-id"); + try { + clients.get(clientRep.getId()).update(clientRep); + Assert.fail(); + } catch (Exception e) { + + } + query = clients.findByClientId(TEST_APP_FLOW); + clientRep = query.get(0); + Assert.assertEquals(browserFlowId, clientRep.getAuthenticationFlowBindingOverrides().get(AuthenticationFlowBindings.BROWSER_BINDING)); + } } diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js index 381a4c20de..038b1ddd7c 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js @@ -832,6 +832,10 @@ module.controller('ClientInstallationCtrl', function($scope, realm, client, serv module.controller('ClientDetailCtrl', function($scope, realm, client, templates, flows, $route, serverInfo, Client, ClientDescriptionConverter, Components, ClientStorageOperations, $location, $modal, Dialog, Notifications) { $scope.flows = []; $scope.clientFlows = []; + var emptyFlow = { + id: "", + alias: "" + } for (var i=0 ; i{{:: 'browser-flow' | translate}}
-
@@ -451,7 +451,7 @@
-