Added ProviderConfigProperty.CLIENT_LIST and refactor role federation mapper to use it
This commit is contained in:
parent
ce6576ce84
commit
98dd87efbc
10 changed files with 31 additions and 31 deletions
|
@ -35,11 +35,6 @@ public abstract class AbstractLDAPFederationMapperFactory implements UserFederat
|
||||||
public void postInit(KeycloakSessionFactory factory) {
|
public void postInit(KeycloakSessionFactory factory) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ProviderConfigProperty> getConfigProperties() {
|
|
||||||
throw new IllegalStateException("Method not supported for this implementation");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class FullNameLDAPFederationMapperFactory extends AbstractLDAPFederationM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProviderConfigProperty> getConfigProperties(RealmModel realm) {
|
public List<ProviderConfigProperty> getConfigProperties() {
|
||||||
return configProperties;
|
return configProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,10 @@ public class RoleLDAPFederationMapperFactory extends AbstractLDAPFederationMappe
|
||||||
"If true, then LDAP role mappings will be mapped to realm role mappings in Keycloak. Otherwise it will be mapped to client role mappings", ProviderConfigProperty.BOOLEAN_TYPE, "true");
|
"If true, then LDAP role mappings will be mapped to realm role mappings in Keycloak. Otherwise it will be mapped to client role mappings", ProviderConfigProperty.BOOLEAN_TYPE, "true");
|
||||||
configProperties.add(useRealmRolesMappings);
|
configProperties.add(useRealmRolesMappings);
|
||||||
|
|
||||||
// NOTE: ClientID will be computed dynamically from available clients
|
ProviderConfigProperty clientIdProperty = createConfigProperty(RoleLDAPFederationMapper.CLIENT_ID, "Client ID",
|
||||||
|
"Client ID of client to which LDAP role mappings will be mapped. Applicable just if 'Use Realm Roles Mapping' is false",
|
||||||
|
ProviderConfigProperty.CLIENT_LIST_TYPE, null);
|
||||||
|
configProperties.add(clientIdProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,18 +81,8 @@ public class RoleLDAPFederationMapperFactory extends AbstractLDAPFederationMappe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProviderConfigProperty> getConfigProperties(RealmModel realm) {
|
public List<ProviderConfigProperty> getConfigProperties() {
|
||||||
List<ProviderConfigProperty> props = new ArrayList<ProviderConfigProperty>(configProperties);
|
return configProperties;
|
||||||
|
|
||||||
Map<String, ClientModel> clients = realm.getClientNameMap();
|
|
||||||
List<String> clientIds = new ArrayList<String>(clients.keySet());
|
|
||||||
|
|
||||||
ProviderConfigProperty clientIdProperty = createConfigProperty(RoleLDAPFederationMapper.CLIENT_ID, "Client ID",
|
|
||||||
"Client ID of client to which LDAP role mappings will be mapped. Applicable just if 'Use Realm Roles Mapping' is false",
|
|
||||||
ProviderConfigProperty.LIST_TYPE, clientIds);
|
|
||||||
props.add(clientIdProperty);
|
|
||||||
|
|
||||||
return props;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class UserAttributeLDAPFederationMapperFactory extends AbstractLDAPFedera
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProviderConfigProperty> getConfigProperties(RealmModel realm) {
|
public List<ProviderConfigProperty> getConfigProperties() {
|
||||||
return configProperties;
|
return configProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -984,7 +984,10 @@ module.config([ '$routeProvider', function($routeProvider) {
|
||||||
},
|
},
|
||||||
mapper : function(UserFederationMapperLoader) {
|
mapper : function(UserFederationMapperLoader) {
|
||||||
return UserFederationMapperLoader();
|
return UserFederationMapperLoader();
|
||||||
}
|
},
|
||||||
|
clients : function(ClientListLoader) {
|
||||||
|
return ClientListLoader();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
controller : 'UserFederationMapperCtrl'
|
controller : 'UserFederationMapperCtrl'
|
||||||
})
|
})
|
||||||
|
@ -1000,6 +1003,9 @@ module.config([ '$routeProvider', function($routeProvider) {
|
||||||
mapperTypes : function(UserFederationMapperTypesLoader) {
|
mapperTypes : function(UserFederationMapperTypesLoader) {
|
||||||
return UserFederationMapperTypesLoader();
|
return UserFederationMapperTypesLoader();
|
||||||
},
|
},
|
||||||
|
clients : function(ClientListLoader) {
|
||||||
|
return ClientListLoader();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
controller : 'UserFederationMapperCreateCtrl'
|
controller : 'UserFederationMapperCreateCtrl'
|
||||||
})
|
})
|
||||||
|
|
|
@ -754,10 +754,11 @@ module.controller('UserFederationMapperListCtrl', function($scope, $location, No
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.controller('UserFederationMapperCtrl', function($scope, realm, provider, mapperTypes, mapper, UserFederationMapper, Notifications, Dialog, $location) {
|
module.controller('UserFederationMapperCtrl', function($scope, realm, provider, mapperTypes, mapper, clients, UserFederationMapper, Notifications, Dialog, $location) {
|
||||||
console.log('UserFederationMapperCtrl');
|
console.log('UserFederationMapperCtrl');
|
||||||
$scope.realm = realm;
|
$scope.realm = realm;
|
||||||
$scope.provider = provider;
|
$scope.provider = provider;
|
||||||
|
$scope.clients = clients;
|
||||||
$scope.create = false;
|
$scope.create = false;
|
||||||
$scope.mapper = angular.copy(mapper);
|
$scope.mapper = angular.copy(mapper);
|
||||||
$scope.changed = false;
|
$scope.changed = false;
|
||||||
|
@ -780,10 +781,10 @@ module.controller('UserFederationMapperCtrl', function($scope, realm, provider,
|
||||||
$location.url("/realms/" + realm.realm + '/user-federation/providers/' + provider.providerName + '/' + provider.id + '/mappers/' + mapper.id);
|
$location.url("/realms/" + realm.realm + '/user-federation/providers/' + provider.providerName + '/' + provider.id + '/mappers/' + mapper.id);
|
||||||
Notifications.success("Your changes have been saved.");
|
Notifications.success("Your changes have been saved.");
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
if (error.status == 400) {
|
if (error.status == 400 && error.data.error_description) {
|
||||||
Notifications.error('Error in configuration of mapper: ' + error.data.error_description);
|
Notifications.error('Error in configuration of mapper: ' + error.data.error_description);
|
||||||
} else {
|
} else {
|
||||||
Notification.error('Unexpected error when creating mapper');
|
Notifications.error('Unexpected error when creating mapper');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -808,10 +809,11 @@ module.controller('UserFederationMapperCtrl', function($scope, realm, provider,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.controller('UserFederationMapperCreateCtrl', function($scope, realm, provider, mapperTypes, UserFederationMapper, Notifications, Dialog, $location) {
|
module.controller('UserFederationMapperCreateCtrl', function($scope, realm, provider, mapperTypes, clients, UserFederationMapper, Notifications, Dialog, $location) {
|
||||||
console.log('UserFederationMapperCreateCtrl');
|
console.log('UserFederationMapperCreateCtrl');
|
||||||
$scope.realm = realm;
|
$scope.realm = realm;
|
||||||
$scope.provider = provider;
|
$scope.provider = provider;
|
||||||
|
$scope.clients = clients;
|
||||||
$scope.create = true;
|
$scope.create = true;
|
||||||
$scope.mapper = { federationProviderDisplayName: provider.displayName, config: {}};
|
$scope.mapper = { federationProviderDisplayName: provider.displayName, config: {}};
|
||||||
$scope.mapperTypes = mapperTypes;
|
$scope.mapperTypes = mapperTypes;
|
||||||
|
@ -844,10 +846,10 @@ module.controller('UserFederationMapperCreateCtrl', function($scope, realm, prov
|
||||||
$location.url('/realms/' + realm.realm +'/user-federation/providers/' + provider.providerName + '/' + provider.id + '/mappers/' + id);
|
$location.url('/realms/' + realm.realm +'/user-federation/providers/' + provider.providerName + '/' + provider.id + '/mappers/' + id);
|
||||||
Notifications.success("Mapper has been created.");
|
Notifications.success("Mapper has been created.");
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
if (error.status == 400) {
|
if (error.status == 400 && error.data.error_description) {
|
||||||
Notifications.error('Error in configuration of mapper: ' + error.data.error_description);
|
Notifications.error('Error in configuration of mapper: ' + error.data.error_description);
|
||||||
} else {
|
} else {
|
||||||
Notification.error('Unexpected error when creating mapper');
|
Notifications.error('Unexpected error when creating mapper');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<div data-ng-repeat="option in mapperType.properties" class="form-group">
|
<div data-ng-repeat="option in mapperType.properties" class="form-group">
|
||||||
<label class="col-md-2 control-label">{{option.label}}</label>
|
<label class="col-md-2 control-label">{{option.label}}</label>
|
||||||
|
|
||||||
<div class="col-sm-4" data-ng-hide="option.type == 'boolean' || option.type == 'List'">
|
<div class="col-sm-4" data-ng-show="option.type == 'String'">
|
||||||
<input class="form-control" type="text" data-ng-model="mapper.config[ option.name ]">
|
<input class="form-control" type="text" data-ng-model="mapper.config[ option.name ]">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4" data-ng-show="option.type == 'boolean'">
|
<div class="col-sm-4" data-ng-show="option.type == 'boolean'">
|
||||||
|
@ -58,6 +58,11 @@
|
||||||
<option value="" selected> Select one... </option>
|
<option value="" selected> Select one... </option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-sm-4" data-ng-show="option.type == 'ClientList'">
|
||||||
|
<select ng-model="mapper.config[ option.name ]" ng-options="client.clientId as client.clientId for client in clients">
|
||||||
|
<option value="" selected> Select one... </option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<kc-tooltip>{{option.helpText}}</kc-tooltip>
|
<kc-tooltip>{{option.helpText}}</kc-tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,4 @@ public interface UserFederationMapperFactory extends ProviderFactory<UserFederat
|
||||||
*/
|
*/
|
||||||
void validateConfig(UserFederationMapperModel mapperModel) throws MapperConfigValidationException;
|
void validateConfig(UserFederationMapperModel mapperModel) throws MapperConfigValidationException;
|
||||||
|
|
||||||
// TODO: Remove this and add realm to the method on ConfiguredProvider?
|
|
||||||
List<ProviderConfigProperty> getConfigProperties(RealmModel realm);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ public class ProviderConfigProperty {
|
||||||
public static final String BOOLEAN_TYPE="boolean";
|
public static final String BOOLEAN_TYPE="boolean";
|
||||||
public static final String STRING_TYPE="String";
|
public static final String STRING_TYPE="String";
|
||||||
public static final String LIST_TYPE="List";
|
public static final String LIST_TYPE="List";
|
||||||
|
public static final String CLIENT_LIST_TYPE="ClientList";
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String label;
|
protected String label;
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class UserFederationProviderResource {
|
||||||
rep.setCategory(mapperFactory.getDisplayCategory());
|
rep.setCategory(mapperFactory.getDisplayCategory());
|
||||||
rep.setName(mapperFactory.getDisplayType());
|
rep.setName(mapperFactory.getDisplayType());
|
||||||
rep.setHelpText(mapperFactory.getHelpText());
|
rep.setHelpText(mapperFactory.getHelpText());
|
||||||
List<ProviderConfigProperty> configProperties = mapperFactory.getConfigProperties(realm);
|
List<ProviderConfigProperty> configProperties = mapperFactory.getConfigProperties();
|
||||||
for (ProviderConfigProperty prop : configProperties) {
|
for (ProviderConfigProperty prop : configProperties) {
|
||||||
ConfigPropertyRepresentation propRep = new ConfigPropertyRepresentation();
|
ConfigPropertyRepresentation propRep = new ConfigPropertyRepresentation();
|
||||||
propRep.setName(prop.getName());
|
propRep.setName(prop.getName());
|
||||||
|
|
Loading…
Reference in a new issue