mirror of https://github.com/apache/archiva.git
[MRM-1736] map roles to ldap groups
ui part. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1446589 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e176de5243
commit
4f75fa5daa
|
@ -1257,7 +1257,10 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
this.ldapGroups.subscribe(function(newValue){self.modified(true)});
|
this.ldapGroups.subscribe(function(newValue){self.modified(true)});
|
||||||
|
|
||||||
this.ldapGroupMappings=ko.observableArray([]);
|
this.ldapGroupMappings=ko.observableArray([]);
|
||||||
this.ldapGroupMappings.subscribe(function(newValue){self.modified(true);});
|
this.ldapGroupMappings.subscribe(function(newValue){
|
||||||
|
self.modified(true);
|
||||||
|
$.log('ldapGroupMappings modified:'+newValue.group);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,13 +1282,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
|
|
||||||
if (!$.isArray(configurationPropertiesEntries)){
|
if (!$.isArray(configurationPropertiesEntries)){
|
||||||
configurationPropertiesEntries=[];
|
configurationPropertiesEntries=[];
|
||||||
} else {
|
|
||||||
configurationPropertiesEntries = $.each(configurationPropertiesEntries,function(item){
|
|
||||||
$.log("each configurationPropertiesEntries");
|
|
||||||
$.log("key:"+item);
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
redbackRuntimeConfiguration.configurationPropertiesEntries(configurationPropertiesEntries);
|
redbackRuntimeConfiguration.configurationPropertiesEntries(configurationPropertiesEntries);
|
||||||
redbackRuntimeConfiguration.modified(false);
|
redbackRuntimeConfiguration.modified(false);
|
||||||
return redbackRuntimeConfiguration;
|
return redbackRuntimeConfiguration;
|
||||||
|
@ -1388,11 +1386,29 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
rowText: "value"
|
rowText: "value"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
pageSize: 10,//self.redbackRuntimeConfiguration().configurationPropertiesEntries.length,
|
pageSize: 10,
|
||||||
gridUpdateCallBack: function(){
|
gridUpdateCallBack: function(){
|
||||||
activatePopoverDoc();
|
activatePopoverDoc();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.ldapGroupMappingsViewModel=new ko.simpleGrid.viewModel({
|
||||||
|
data: self.redbackRuntimeConfiguration().ldapGroupMappings,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
headerText: $.i18n.prop('redback.runtime.ldap.mapping.group.label'),
|
||||||
|
rowText: "group"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headerText: $.i18n.prop('redback.runtime.ldap.mapping.roles.label'),
|
||||||
|
rowText: "value"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
pageSize: 10,
|
||||||
|
gridUpdateCallBack: function(){
|
||||||
|
activatePopoverDoc();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
findUserManagerImplementationInformation=function(id){
|
findUserManagerImplementationInformation=function(id){
|
||||||
for(var i= 0;i<self.userManagerImplementationInformations().length;i++){
|
for(var i= 0;i<self.userManagerImplementationInformations().length;i++){
|
||||||
|
@ -1553,6 +1569,10 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modifyLdapGroupMapping=function(ldapGroupMapping){
|
||||||
|
$.log('modifyLdapGroupMapping');
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
UserManagerImplementationInformation=function(beanId,descriptionKey,readOnly){
|
UserManagerImplementationInformation=function(beanId,descriptionKey,readOnly){
|
||||||
|
@ -1643,31 +1663,26 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
var redbackRuntimeConfigurationViewModel =
|
var redbackRuntimeConfigurationViewModel =
|
||||||
new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
|
new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
|
||||||
|
|
||||||
|
var groups=[];
|
||||||
|
|
||||||
// load ldap roles
|
// load ldap roles
|
||||||
$.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", {
|
$.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
complete: function(data) {
|
success: function(data){
|
||||||
var groups = [];
|
groups = mapStringList(data);
|
||||||
if(data&&data.strings){
|
|
||||||
groups = $.isArray(data.strings)? $.map(data.strings,function(item){
|
|
||||||
return item;
|
|
||||||
}):[data.strings];
|
|
||||||
}
|
|
||||||
$.log("groups number:"+groups.length);
|
$.log("groups number:"+groups.length);
|
||||||
redbackRuntimeConfiguration.ldapGroups.push(groups);
|
redbackRuntimeConfiguration.ldapGroups=ko.observableArray(groups);
|
||||||
|
},
|
||||||
|
complete: function(data) {
|
||||||
|
|
||||||
|
|
||||||
// load ldap group mappings if any
|
// load ldap group mappings if any
|
||||||
$.ajax("restServices/redbackServices/ldapGroupMappingService", {
|
$.ajax("restServices/redbackServices/ldapGroupMappingService", {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var groupMappings=mapLdapGroupMappings(data);
|
var groupMappings=mapLdapGroupMappings(data,redbackRuntimeConfigurationViewModel.modifyLdapGroupMapping);
|
||||||
|
|
||||||
redbackRuntimeConfiguration.ldapGroupMappings(groupMappings);
|
|
||||||
redbackRuntimeConfiguration.modified(false);
|
|
||||||
|
|
||||||
|
|
||||||
$.ajax("restServices/redbackServices/roleManagementService/allRoles", {
|
$.ajax("restServices/redbackServices/roleManagementService/allRoles", {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
|
@ -1679,6 +1694,24 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
});
|
});
|
||||||
|
|
||||||
redbackRuntimeConfigurationViewModel.allRoleNames=allRoleNames;
|
redbackRuntimeConfigurationViewModel.allRoleNames=allRoleNames;
|
||||||
|
if (redbackRuntimeConfiguration.ldapConfiguration().useRoleNameAsGroup()) {
|
||||||
|
// if using groups == roles add all as mapping except already mapped
|
||||||
|
$.each(groups,function(idx,item){
|
||||||
|
var exists=false;
|
||||||
|
// avoid duplicate if mapping really exists !
|
||||||
|
$.each(groupMappings,function(idx2,groupMapping){
|
||||||
|
if(groupMapping.group()==item){
|
||||||
|
exists=true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(!exists){
|
||||||
|
groupMappings.push(new LdapGroupMapping(item,[item],true,redbackRuntimeConfigurationViewModel.modifyLdapGroupMapping));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
redbackRuntimeConfiguration.ldapGroupMappings=ko.observableArray(groupMappings);
|
||||||
|
redbackRuntimeConfiguration.modified(false);
|
||||||
|
|
||||||
mainContent.html( $("#redback-runtime-configuration-main" ).tmpl() );
|
mainContent.html( $("#redback-runtime-configuration-main" ).tmpl() );
|
||||||
ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#redback-runtime-configuration-content" ).get(0));
|
ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#redback-runtime-configuration-content" ).get(0));
|
||||||
|
@ -1704,22 +1737,35 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LdapGroupMapping=function(group,roleNames){
|
LdapGroupMapping=function(group,roleNames,automatic,subscribeFn){
|
||||||
var self=this;
|
var self=this;
|
||||||
this.modified=ko.observable(false);
|
this.modified=ko.observable(false);
|
||||||
//private String group;
|
//private String group;
|
||||||
this.group=ko.observable(group);
|
this.group=ko.observable(group);
|
||||||
this.group.subscribe(function(newValue){self.modified(true)});
|
this.group.subscribe(function(newValue){
|
||||||
|
self.modified(true);
|
||||||
|
if(subscribeFn){
|
||||||
|
subscribeFn(newValue)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//private Collection<String> roleNames;
|
//private Collection<String> roleNames;
|
||||||
this.roleNames=ko.observableArray(roleNames);
|
this.roleNames=ko.observableArray(roleNames);
|
||||||
this.roleNames.subscribe(function(newValue){self.modified(true)});
|
this.roleNames.subscribe(function(newValue){
|
||||||
|
self.modified(true);
|
||||||
|
$.log("roleNames modified");
|
||||||
|
if(subscribeFn){
|
||||||
|
subscribeFn(newValue)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.automatic=automatic?automatic:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapLdapGroupMappings=function(data){
|
mapLdapGroupMappings=function(data,modifyLdapGroupMapping){
|
||||||
if(data!=null){
|
if(data!=null){
|
||||||
return $.map(data,function(item){
|
return $.map(data,function(item){
|
||||||
return new LdapGroupMapping(item.group,item.roleNames?item.roleNames:[]);
|
return new LdapGroupMapping(item.group,item.roleNames?item.roleNames:[],false,modifyLdapGroupMapping);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -1131,13 +1131,12 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tab-pane" id="redback-runtime-ldap-mapping" data-bind='template: {name:"redback-runtime-ldap-mapping-tmpl",data: redbackRuntimeConfiguration}'>
|
<div class="tab-pane" id="redback-runtime-ldap-mapping" data-bind='template: {name:"redback-runtime-ldap-mapping-tmpl",data: redbackRuntimeConfiguration}'>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tab-pane" id="redback-runtime-properties-content">
|
<div class="tab-pane" id="redback-runtime-properties-content">
|
||||||
|
|
||||||
<div class="well">
|
<div class="well">
|
||||||
<table id="proxyConnectorsTable" class="table-hover"
|
<table id="propertiesTable" class="table-hover"
|
||||||
data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'properties-grid',pageLinksId:'properties-grid-pagination'">
|
data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'properties-grid',pageLinksId:'properties-grid-pagination'">
|
||||||
</table>
|
</table>
|
||||||
<div id="properties-grid-pagination"></div>
|
<div id="properties-grid-pagination"></div>
|
||||||
|
@ -1261,7 +1260,6 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue