"New virtual host" (not finished)
This commit is contained in:
parent
11ed0e260f
commit
c759234a9a
|
@ -43,7 +43,7 @@ sub unserialize {
|
|||
while ( my ( $k, $v ) = each(%$fields) ) {
|
||||
$v =~ s/^'(.*)'$/$1/s;
|
||||
if ( $k =~
|
||||
/^(?:exportedVars|locationRules|groups|exportedHeaders|macros|globalStorageOptions)$/
|
||||
/^(?:exportedVars|locationRules|groups|exportedHeaders|macros|globalStorageOptions|notificationStorageOptions)$/
|
||||
and $v ||= {}
|
||||
and not ref($v) )
|
||||
{
|
||||
|
|
|
@ -117,8 +117,9 @@ function rules(id){
|
|||
$('#newrb').css('display','');
|
||||
}
|
||||
function rulesRoot(id){
|
||||
currentId=id;
|
||||
display('default','Lemonldap::NG Manager');
|
||||
$('#newrbr').css('display','');
|
||||
$('#newrbr').css('display','block');
|
||||
}
|
||||
function reloadAuthParams() {
|
||||
setlmdata(currentId,$('#authText').attr('value'));
|
||||
|
@ -161,6 +162,14 @@ function newKey(){
|
|||
});
|
||||
return false;
|
||||
}
|
||||
function newRuleR(){
|
||||
var newIdValue=newId(currentId);
|
||||
simpleTreeCollection[0].addNode(newIdValue,text4newKey,function(d,s){
|
||||
$('>span',s).attr('onClick','rules("'+newIdValue+'")').attr('name',text4newKey).attr('value',value4newKey).attr('id','text_'+newIdValue);
|
||||
rules(newIdValue);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
function newRule(){
|
||||
var newIdValue=newId(currentId);
|
||||
simpleTreeCollection[0].newNodeAfter(newIdValue,text4newKey,function(d,s){
|
||||
|
@ -173,6 +182,12 @@ function delKey(){
|
|||
$('#'+currentId).prev().remove();
|
||||
$('#'+currentId).remove();
|
||||
}
|
||||
function newVh(name){
|
||||
var vhId='li_'+myB64('/locationRules/'+name);
|
||||
simpleTreeCollection[0].newAjaxNodeIn($('#li_L3ZpcnR1YWxIb3N0cw2'),vhId,name,scriptname+'?type=new&node=virtualHosts/'+name,function(d,s){
|
||||
$('>span',s).attr('name',name).attr('help','default').attr('id','text_'+vhId);
|
||||
});
|
||||
}
|
||||
function uploadConf(){
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
|
@ -207,3 +222,35 @@ function uploadConf(){
|
|||
}
|
||||
});
|
||||
}
|
||||
/* Warning, it's not a real base64 */
|
||||
function myB64(s) {
|
||||
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||||
var i=0;
|
||||
var res="";
|
||||
var s2="";
|
||||
while (i < s.length) {
|
||||
chr1 = s.charCodeAt(i++);
|
||||
chr2 = s.charCodeAt(i++);
|
||||
chr3 = s.charCodeAt(i++);
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
res+=keyStr.charAt(enc1)+keyStr.charAt(enc2);
|
||||
if (isNaN(chr2)) {
|
||||
res+='2';
|
||||
break;
|
||||
}
|
||||
res+=keyStr.charAt(enc3);
|
||||
if (isNaN(chr3)) {
|
||||
res+='1';
|
||||
break;
|
||||
}
|
||||
res+=keyStr.charAt(enc4);
|
||||
if(i==s.length) {
|
||||
res+='0';
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ var scriptname='<TMPL_VAR NAME="SCRIPT_NAME">';var imagepath='<TMPL_VAR NAME="DI
|
|||
<lang en="Apply" fr="Appliquer" />
|
||||
</button>
|
||||
|
||||
<button id="bnewvh" onclick="newVh('test25.example.com');return false;" class="ui-state-default ui-corner-all">
|
||||
<lang en="New virtual host" fr="Nouvel hôte virtuel" />
|
||||
</button>
|
||||
|
||||
<button id="newkbr" style="display:none;" onclick="newKeyR();return false;" class="ui-state-default ui-corner-all">
|
||||
<lang en="New key" fr="Nouvelle clef" />
|
||||
</button>
|
||||
|
|
|
@ -431,12 +431,16 @@ $.fn.simpleTree = function(opt){
|
|||
};
|
||||
|
||||
TREE.addNode = function(id, text, callback)
|
||||
{
|
||||
TREE.newNodeIn(TREE.getSelected(),id,text,callback);
|
||||
};
|
||||
TREE.newNodeIn = function(node, id, text, callback)
|
||||
{
|
||||
var temp_node = $('<li><ul><li id="'+id+'"><span>'+text+'</span></li></ul></li>');
|
||||
TREE.setTreeNodes(temp_node);
|
||||
dragNode_destination = TREE.getSelected();
|
||||
TREE.setTreeNodes(temp_node,true);
|
||||
destination = node;
|
||||
dragNode_source = $('.doc-last',temp_node);
|
||||
TREE.moveNodeToFolder(dragNode_destination);
|
||||
TREE.moveNodeToFolder(destination);
|
||||
temp_node.remove();
|
||||
if(typeof(callback) == 'function')
|
||||
{
|
||||
|
@ -445,18 +449,20 @@ $.fn.simpleTree = function(opt){
|
|||
};
|
||||
TREE.newNodeAfter = function(id, text, callback)
|
||||
{
|
||||
var temp_node = $('<li><ul><li id="'+id+'"><span>'+text+'</span></li></u></li>');
|
||||
TREE.newNodeIn(TREE.getSelected().parent().parent(),id,text,callback);
|
||||
};
|
||||
TREE.newAjaxNodeIn = function(node,id,text,url,callback)
|
||||
{
|
||||
var temp_node = $('<li><ul><li id="'+id+'"><span>'+text+'</span><ul class="ajax"><li id="new">.{url:'+url+'}</li></ul></li></ul></li>');
|
||||
TREE.setTreeNodes(temp_node,true);
|
||||
destination = TREE.getSelected().parent().parent();
|
||||
dragNode_source = $('.doc-last',temp_node);
|
||||
destination = node;
|
||||
dragNode_source = $('.folder-close-last',temp_node);
|
||||
TREE.moveNodeToFolder(destination);
|
||||
temp_node.remove();
|
||||
if(typeof(callback) == 'function')
|
||||
{
|
||||
callback(dragNode_destination, dragNode_source);
|
||||
}
|
||||
//existing.after(temp_node);
|
||||
//temp_node.remove();
|
||||
};
|
||||
TREE.delNode = function(callback)
|
||||
{
|
||||
|
|
|
@ -130,7 +130,16 @@ sub confNode {
|
|||
# Hash datas
|
||||
elsif ( $target =~ s/^hash:// ) {
|
||||
my $h = $self->keyToH( $target, $self->conf );
|
||||
return unless ($h);
|
||||
unless ($h) {
|
||||
my $tmp;
|
||||
unless ( ($tmp) = ( $target =~ /^\/?(.*)\// )
|
||||
and $h = $self->subDefaultConf()->{$tmp} )
|
||||
{
|
||||
$self->lmLog( "$target hash is not defined in configuration",
|
||||
'error' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
foreach ( sort keys %$h ) {
|
||||
if ( ref( $h->{$_} ) ) {
|
||||
$res .= $self->confNode( "$target/$_", $help, $js );
|
||||
|
@ -287,8 +296,8 @@ sub conf {
|
|||
$self->abort( 'Unable to get configuration',
|
||||
$Lemonldap::NG::Common::Conf::msg )
|
||||
unless ( $self->{_conf} );
|
||||
if(my $c = $self->param('conf')){
|
||||
$self->{_conf}->{$_} = $self->param($_) foreach(split /\s+/,$c);
|
||||
if ( my $c = $self->param('conf') ) {
|
||||
$self->{_conf}->{$_} = $self->param($_) foreach ( split /\s+/, $c );
|
||||
}
|
||||
return $self->{_conf};
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ sub confUpload {
|
|||
foreach ( @{ $result->getChildrenByTagName('ignore') } ) {
|
||||
my $node = $_->getAttribute('value');
|
||||
$node =~ s/^.*node=(.*?)(?:&.*)?\}$/$1/;
|
||||
foreach my $k ( $self->findAllConfKeys( $self->corresp( $node, 1 ) ) ) {
|
||||
foreach my $k ( $self->findAllConfKeys( $self->corresp( $node ) ) ) {
|
||||
my $v = $self->keyToH( $k, $self->conf );
|
||||
$v = $self->keyToH( $k, $self->defaultConf ) unless ( defined $v );
|
||||
if ( defined $v ) {
|
||||
|
|
|
@ -26,8 +26,10 @@ sub cstruct {
|
|||
_nodes => ["hash:/locationRules/$k:rules:rules"],
|
||||
_js => 'rulesRoot'
|
||||
},
|
||||
headers =>
|
||||
{ _nodes => ["hash:/exportedHeaders/$k"], _js => 'hashRoot' },
|
||||
headers => {
|
||||
_nodes => ["hash:/exportedHeaders/$k"],
|
||||
_js => 'hashRoot'
|
||||
},
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -61,11 +63,9 @@ sub struct {
|
|||
# Displayed nodes depend on authentication/userDB modules choosed
|
||||
_nodes => sub {
|
||||
my $self = shift;
|
||||
my $auth =
|
||||
$self->conf->{authentication}
|
||||
my $auth = $self->conf->{authentication}
|
||||
|| $self->defaultConf()->{authentication};
|
||||
my $udb =
|
||||
$self->conf->{userDB}
|
||||
my $udb = $self->conf->{userDB}
|
||||
|| $self->defaultConf()->{userDB};
|
||||
$auth = lc($auth);
|
||||
$udb = lc($udb);
|
||||
|
@ -415,6 +415,7 @@ sub defaultConf {
|
|||
cda => '0',
|
||||
cookieName => 'lemonldap',
|
||||
domain => 'example.com',
|
||||
exportedHeaders => { 'test.example.com' => { 'Auth-User' => '$uid' }, },
|
||||
exportedVars => { cn => 'cn', mail => 'mail', uid => 'uid', },
|
||||
globalStorage => 'Apache::Session::File',
|
||||
globalStorageOptions => {
|
||||
|
@ -425,6 +426,7 @@ sub defaultConf {
|
|||
ldapBase => 'dc=example,dc=com',
|
||||
ldapPort => '389',
|
||||
ldapServer => 'localhost',
|
||||
locationRules => { 'test.example.com' => { default => 'accept' }, },
|
||||
managerDn => '',
|
||||
managerPassword => '',
|
||||
notification => '0',
|
||||
|
@ -449,4 +451,11 @@ sub defaultConf {
|
|||
};
|
||||
}
|
||||
|
||||
sub subDefaultConf {
|
||||
return {
|
||||
locationRules => { default => 'deny' },
|
||||
exportedHeaders => { 'Auth-User' => '$uid' },
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user