Merge pull request #1598 from mposolda/master
KEYCLOAK-1801 Additional fix and cleanup
This commit is contained in:
commit
2550d16127
10 changed files with 65 additions and 95 deletions
|
@ -638,6 +638,9 @@ module.config([ '$routeProvider', function($routeProvider) {
|
|||
},
|
||||
clientAuthenticatorProviders : function(ClientAuthenticatorProvidersLoader) {
|
||||
return ClientAuthenticatorProvidersLoader();
|
||||
},
|
||||
clientConfigProperties: function(PerClientAuthenticationConfigDescriptionLoader) {
|
||||
return PerClientAuthenticationConfigDescriptionLoader();
|
||||
}
|
||||
},
|
||||
controller : 'ClientCredentialsCtrl'
|
||||
|
|
|
@ -30,39 +30,12 @@ module.controller('ClientRoleListCtrl', function($scope, $location, realm, clien
|
|||
});
|
||||
});
|
||||
|
||||
module.controller('ClientCredentialsCtrl', function($scope, $location, realm, client, clientAuthenticatorProviders, Client) {
|
||||
module.controller('ClientCredentialsCtrl', function($scope, $location, realm, client, clientAuthenticatorProviders, clientConfigProperties, Client) {
|
||||
$scope.realm = realm;
|
||||
$scope.client = angular.copy(client);
|
||||
$scope.clientAuthenticatorProviders = clientAuthenticatorProviders;
|
||||
|
||||
var updateConfigButtonVisibility = function() {
|
||||
for (var i=0 ; i<clientAuthenticatorProviders.length ; i++) {
|
||||
var authenticator = clientAuthenticatorProviders[i];
|
||||
if ($scope.client.clientAuthenticatorType === authenticator.id) {
|
||||
$scope.configButtonVisible = authenticator.configurablePerClient;
|
||||
}
|
||||
}
|
||||
};
|
||||
updateConfigButtonVisibility();
|
||||
|
||||
$scope.$watch('client', function() {
|
||||
if (!angular.equals($scope.client, client)) {
|
||||
|
||||
console.log("Update client credentials!");
|
||||
|
||||
Client.update({
|
||||
realm : realm.realm,
|
||||
client : client.id
|
||||
}, $scope.client, function() {
|
||||
$scope.changed = false;
|
||||
client = angular.copy($scope.client);
|
||||
updateConfigButtonVisibility();
|
||||
});
|
||||
|
||||
}
|
||||
}, true);
|
||||
|
||||
$scope.$watch('client.clientAuthenticatorType', function(val) {
|
||||
var updateCurrentPartial = function(val) {
|
||||
$scope.clientAuthenticatorConfigPartial;
|
||||
switch(val) {
|
||||
case 'client-secret':
|
||||
|
@ -72,14 +45,28 @@ module.controller('ClientCredentialsCtrl', function($scope, $location, realm, cl
|
|||
$scope.clientAuthenticatorConfigPartial = 'client-credentials-jwt.html';
|
||||
break;
|
||||
default:
|
||||
$scope.currentAuthenticatorConfigProperties = clientConfigProperties[val];
|
||||
$scope.clientAuthenticatorConfigPartial = 'client-credentials-generic.html';
|
||||
break;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.configureAuthenticator = function() {
|
||||
$location.url("/realms/" + realm.realm + "/clients/" + client.id + "/credentials/" + client.clientAuthenticatorType);
|
||||
}
|
||||
updateCurrentPartial(client.clientAuthenticatorType);
|
||||
|
||||
$scope.$watch('client.clientAuthenticatorType', function() {
|
||||
if (!angular.equals($scope.client.clientAuthenticatorType, client.clientAuthenticatorType)) {
|
||||
|
||||
Client.update({
|
||||
realm : realm.realm,
|
||||
client : client.id
|
||||
}, $scope.client, function() {
|
||||
$scope.changed = false;
|
||||
client = angular.copy($scope.client);
|
||||
updateCurrentPartial(client.clientAuthenticatorType)
|
||||
});
|
||||
|
||||
}
|
||||
}, true);
|
||||
|
||||
});
|
||||
|
||||
|
@ -134,17 +121,15 @@ module.controller('ClientSignedJWTCtrl', function($scope, $location, ClientCerti
|
|||
};
|
||||
});
|
||||
|
||||
module.controller('ClientGenericCredentialsCtrl', function($scope, $location, realm, client, clientConfigProperties, Client, Notifications) {
|
||||
module.controller('ClientGenericCredentialsCtrl', function($scope, $location, Client, Notifications) {
|
||||
|
||||
console.log('ClientGenericCredentialsCtrl invoked');
|
||||
|
||||
$scope.realm = realm;
|
||||
$scope.client = angular.copy(client);
|
||||
$scope.clientConfigProperties = clientConfigProperties;
|
||||
$scope.clientCopy = angular.copy($scope.client);
|
||||
$scope.changed = false;
|
||||
|
||||
$scope.$watch('client', function() {
|
||||
if (!angular.equals($scope.client, client)) {
|
||||
if (!angular.equals($scope.client, $scope.clientCopy)) {
|
||||
$scope.changed = true;
|
||||
}
|
||||
}, true);
|
||||
|
@ -152,17 +137,17 @@ module.controller('ClientGenericCredentialsCtrl', function($scope, $location, re
|
|||
$scope.save = function() {
|
||||
|
||||
Client.update({
|
||||
realm : realm.realm,
|
||||
client : client.id
|
||||
realm : $scope.realm.realm,
|
||||
client : $scope.client.id
|
||||
}, $scope.client, function() {
|
||||
$scope.changed = false;
|
||||
client = angular.copy($scope.client);
|
||||
$scope.clientCopy = angular.copy($scope.client);
|
||||
Notifications.success("Client authentication configuration has been saved to the client.");
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reset = function() {
|
||||
$scope.client = angular.copy(client);
|
||||
$scope.client = angular.copy($scope.clientCopy);
|
||||
$scope.changed = false;
|
||||
};
|
||||
});
|
||||
|
|
|
@ -419,10 +419,9 @@ module.factory('AuthenticationConfigDescriptionLoader', function(Loader, Authent
|
|||
});
|
||||
|
||||
module.factory('PerClientAuthenticationConfigDescriptionLoader', function(Loader, PerClientAuthenticationConfigDescription, $route, $q) {
|
||||
return Loader.query(PerClientAuthenticationConfigDescription, function () {
|
||||
return Loader.get(PerClientAuthenticationConfigDescription, function () {
|
||||
return {
|
||||
realm: $route.current.params.realm,
|
||||
provider: $route.current.params.provider
|
||||
realm: $route.current.params.realm
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1258,9 +1258,8 @@ module.factory('AuthenticationConfigDescription', function($resource) {
|
|||
});
|
||||
});
|
||||
module.factory('PerClientAuthenticationConfigDescription', function($resource) {
|
||||
return $resource(authUrl + '/admin/realms/:realm/authentication/per-client-config-description/:provider', {
|
||||
realm : '@realm',
|
||||
provider: '@provider'
|
||||
return $resource(authUrl + '/admin/realms/:realm/authentication/per-client-config-description', {
|
||||
realm : '@realm'
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<form class="form-horizontal" name="credentialForm" novalidate kc-read-only="!access.manageClients" data-ng-show="client.attributes.length > 0">
|
||||
<fieldset>
|
||||
<kc-provider-config realm="realm" config="client.attributes" properties="clientConfigProperties"></kc-provider-config>
|
||||
</fieldset>
|
||||
<div>
|
||||
<form class="form-horizontal" name="credentialForm" novalidate kc-read-only="!access.manageClients" data-ng-show="currentAuthenticatorConfigProperties.length > 0" data-ng-controller="ClientGenericCredentialsCtrl">
|
||||
<fieldset>
|
||||
<kc-provider-config realm="realm" config="client.attributes" properties="currentAuthenticatorConfigProperties"></kc-provider-config>
|
||||
</fieldset>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-10 col-md-offset-2" data-ng-show="access.manageClients">
|
||||
<button kc-save data-ng-disabled="!changed">Save</button>
|
||||
<button kc-reset data-ng-disabled="!changed">Cancel</button>
|
||||
<div class="form-group">
|
||||
<div class="col-md-10 col-md-offset-2" data-ng-show="access.manageClients">
|
||||
<button kc-save data-ng-disabled="!changed">Save</button>
|
||||
<button kc-reset data-ng-disabled="!changed">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
|
@ -25,13 +25,6 @@ public interface ClientAuthenticatorFactory extends ProviderFactory<ClientAuthen
|
|||
@Override
|
||||
boolean isConfigurable();
|
||||
|
||||
/**
|
||||
* Is this authenticator configurable per client? The configuration will be in "Clients" / "Credentials" tab in admin console
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isConfigurablePerClient();
|
||||
|
||||
/**
|
||||
* List of config properties for this client implementation. Those will be shown in admin console in clients credentials tab and can be configured per client.
|
||||
* Applicable only if "isConfigurablePerClient" is true
|
||||
|
|
|
@ -127,11 +127,6 @@ public class ClientIdAndSecretAuthenticator extends AbstractClientAuthenticator
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurablePerClient() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationExecutionModel.Requirement[] getRequirementChoices() {
|
||||
return REQUIREMENT_CHOICES;
|
||||
|
|
|
@ -144,11 +144,6 @@ public class JWTClientAuthenticator extends AbstractClientAuthenticator {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurablePerClient() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationExecutionModel.Requirement[] getRequirementChoices() {
|
||||
return REQUIREMENT_CHOICES;
|
||||
|
|
|
@ -211,11 +211,6 @@ public class AuthenticationManagementResource {
|
|||
data.put("description", configured.getHelpText());
|
||||
data.put("displayName", configured.getDisplayType());
|
||||
|
||||
if (configured instanceof ClientAuthenticatorFactory) {
|
||||
ClientAuthenticatorFactory configuredClient = (ClientAuthenticatorFactory) configured;
|
||||
data.put("configurablePerClient", configuredClient.isConfigurablePerClient());
|
||||
}
|
||||
|
||||
providers.add(data);
|
||||
}
|
||||
return providers;
|
||||
|
@ -894,21 +889,30 @@ public class AuthenticationManagementResource {
|
|||
}
|
||||
|
||||
|
||||
@Path("per-client-config-description/{providerId}")
|
||||
@Path("per-client-config-description")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@NoCache
|
||||
public List<ConfigPropertyRepresentation> getPerClientConfigDescription(@PathParam("providerId") String providerId) {
|
||||
public Map<String, List<ConfigPropertyRepresentation>> getPerClientConfigDescription() {
|
||||
this.auth.requireView();
|
||||
ConfigurableAuthenticatorFactory factory = CredentialHelper.getConfigurableAuthenticatorFactory(session, providerId);
|
||||
ClientAuthenticatorFactory clientAuthFactory = (ClientAuthenticatorFactory) factory;
|
||||
List<ProviderConfigProperty> perClientConfigProps = clientAuthFactory.getConfigPropertiesPerClient();
|
||||
List<ConfigPropertyRepresentation> result = new LinkedList<>();
|
||||
for (ProviderConfigProperty prop : perClientConfigProps) {
|
||||
ConfigPropertyRepresentation propRep = getConfigPropertyRep(prop);
|
||||
result.add(propRep);
|
||||
List<ProviderFactory> factories = session.getKeycloakSessionFactory().getProviderFactories(ClientAuthenticator.class);
|
||||
|
||||
Map<String, List<ConfigPropertyRepresentation>> toReturn = new HashMap<>();
|
||||
for (ProviderFactory clientAuthenticatorFactory : factories) {
|
||||
String providerId = clientAuthenticatorFactory.getId();
|
||||
ConfigurableAuthenticatorFactory factory = CredentialHelper.getConfigurableAuthenticatorFactory(session, providerId);
|
||||
ClientAuthenticatorFactory clientAuthFactory = (ClientAuthenticatorFactory) factory;
|
||||
List<ProviderConfigProperty> perClientConfigProps = clientAuthFactory.getConfigPropertiesPerClient();
|
||||
List<ConfigPropertyRepresentation> result = new LinkedList<>();
|
||||
for (ProviderConfigProperty prop : perClientConfigProps) {
|
||||
ConfigPropertyRepresentation propRep = getConfigPropertyRep(prop);
|
||||
result.add(propRep);
|
||||
}
|
||||
|
||||
toReturn.put(providerId, result);
|
||||
}
|
||||
return result;
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Path("config")
|
||||
|
|
|
@ -68,11 +68,6 @@ public class PassThroughClientAuthenticator extends AbstractClientAuthenticator
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurablePerClient() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationExecutionModel.Requirement[] getRequirementChoices() {
|
||||
return REQUIREMENT_CHOICES;
|
||||
|
|
Loading…
Reference in a new issue