diff --git a/Makefile b/Makefile index f3afe3714..7803a15de 100644 --- a/Makefile +++ b/Makefile @@ -122,12 +122,14 @@ ERASECONFIG=1 # Set to 0 if you do not want to replace your configuration MANAGERJSONSRC= scripts/jsongenerator.pl \ $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build.pm \ $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build/Attributes.pm \ - $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build/Tree.pm + $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Build/Tree.pm \ + $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Conf/Zero.pm MANAGERJSONDST=$(SRCMANAGERDIR)/site/static/struct.json \ $(SRCMANAGERDIR)/site/static/js/conftree.js \ $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Attributes.pm \ $(SRCMANAGERDIR)/lib/Lemonldap/NG/Manager/Constants.pm \ - $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm + $(SRCCOMMONDIR)/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm \ + _example/conf/lmConf-1.js PERLCOMMONSRC:=$(shell find $(SRCCOMMONDIR)/lib -name '*.pm') PERLCOMMONDST=$(SRCCOMMONDIR)/blib/lib/Lemonldap/NG/Common.pm PERLHANDLERSRC:=$(shell find $(SRCHANDLERDIR)/lib -name '*.pm') diff --git a/_example/conf/lmConf-1.js b/_example/conf/lmConf-1.js index 75c48c050..e543dec3f 100644 --- a/_example/conf/lmConf-1.js +++ b/_example/conf/lmConf-1.js @@ -1,145 +1,98 @@ { - "portal" : "http://auth.__DNSDOMAIN__/", - "persistentStorage" : "Apache::Session::File", - "portalSkinBackground" : "1280px-Cedar_Breaks_National_Monument_partially.jpg", - "globalStorageOptions" : { - "LockDirectory" : "__SESSIONDIR__/lock", - "Directory" : "__SESSIONDIR__", - "generateModule" : "Lemonldap::NG::Common::Apache::Session::Generate::SHA256" - }, - "passwordDB" : "Demo", - "locationRules" : { - "test2.__DNSDOMAIN__" : { - "default" : "accept", - "^/logout" : "logout_sso" - }, - "manager.__DNSDOMAIN__" : { - "default" : "$uid eq \"dwho\"" - }, - "test1.__DNSDOMAIN__" : { - "^/logout" : "logout_sso", - "default" : "accept" - } - }, - "cfgNum" : "1", - "exportedVars" : { - "UA" : "HTTP_USER_AGENT" - }, - "authentication" : "Demo", - "mailUrl" : "http://auth.__DNSDOMAIN__/mail.pl", "applicationList" : { "1sample" : { "catname" : "Sample applications", - "test2" : { + "test1" : { "options" : { - "uri" : "http://test2.__DNSDOMAIN__/", + "description" : "A simple application displaying authenticated user", "display" : "auto", - "name" : "Application Test 2", - "description" : "The same simple application displaying authenticated user", - "logo" : "thumbnail.png" + "logo" : "demo.png", + "name" : "Application Test 1", + "uri" : "http://test1.__DNSDOMAIN__/" }, "type" : "application" }, - "test1" : { + "test2" : { "options" : { - "logo" : "demo.png", - "description" : "A simple application displaying authenticated user", - "name" : "Application Test 1", - "uri" : "http://test1.__DNSDOMAIN__/", - "display" : "auto" + "description" : "The same simple application displaying authenticated user", + "display" : "auto", + "logo" : "thumbnail.png", + "name" : "Application Test 2", + "uri" : "http://test2.__DNSDOMAIN__/" + }, + "type" : "application" + }, + "type" : "category" + }, + "2administration" : { + "catname" : "Administration", + "manager" : { + "options" : { + "description" : "Configure LemonLDAP::NG WebSSO", + "display" : "auto", + "logo" : "configure.png", + "name" : "WebSSO Manager", + "uri" : "http://manager.__DNSDOMAIN__/manager.html" + }, + "type" : "application" + }, + "notifications" : { + "options" : { + "description" : "Explore WebSSO notifications", + "display" : "auto", + "logo" : "database.png", + "name" : "Notifications explorer", + "uri" : "http://manager.__DNSDOMAIN__/notifications.html" + }, + "type" : "application" + }, + "sessions" : { + "options" : { + "description" : "Explore WebSSO sessions", + "display" : "auto", + "logo" : "database.png", + "name" : "Sessions explorer", + "uri" : "http://manager.__DNSDOMAIN__/sessions.html" }, "type" : "application" }, "type" : "category" }, "3documentation" : { - "officialwebsite" : { - "type" : "application", - "options" : { - "logo" : "network.png", - "display" : "on", - "uri" : "http://lemonldap-ng.org/", - "description" : "Official LemonLDAP::NG Website", - "name" : "Offical Website" - } - }, + "catname" : "Documentation", "localdoc" : { "options" : { - "logo" : "help.png", - "uri" : "http://manager.__DNSDOMAIN__/doc/", + "description" : "Documentation supplied with LemonLDAP::NG", "display" : "on", + "logo" : "help.png", "name" : "Local documentation", - "description" : "Documentation supplied with LemonLDAP::NG" + "uri" : "http://manager.__DNSDOMAIN__/doc/" }, "type" : "application" }, - "type" : "category", - "catname" : "Documentation" - }, - "2administration" : { - "type" : "category", - "manager" : { + "officialwebsite" : { "options" : { - "logo" : "configure.png", - "uri" : "http://manager.__DNSDOMAIN__/manager.html", - "display" : "auto", - "name" : "WebSSO Manager", - "description" : "Configure LemonLDAP::NG WebSSO" + "description" : "Official LemonLDAP::NG Website", + "display" : "on", + "logo" : "network.png", + "name" : "Offical Website", + "uri" : "http://lemonldap-ng.org/" }, "type" : "application" }, - "sessions" : { - "type" : "application", - "options" : { - "logo" : "database.png", - "uri" : "http://manager.__DNSDOMAIN__/sessions.html", - "display" : "auto", - "description" : "Explore WebSSO sessions", - "name" : "Sessions explorer" - } - }, - "catname" : "Administration", - "notifications" : { - "type" : "application", - "options" : { - "logo" : "database.png", - "uri" : "http://manager.__DNSDOMAIN__/notifications.html", - "display" : "auto", - "description" : "Explore WebSSO notifications", - "name" : "Notifications explorer" - } - } + "type" : "category" } }, - "notificationStorage" : "File", + "authentication" : "Demo", "cfgAuthor" : "The LemonLDAP::NG team", - "sessionDataToRemember" : {}, - "notification" : 1, - "persistentStorageOptions" : { - "Directory" : "__PSESSIONDIR__", - "LockDirectory" : "__PSESSIONDIR__/lock" + "cfgNum" : "1", + "cookieName" : "lemonldap", + "demoExportedVars" : { + "cn" : "cn", + "mail" : "mail", + "uid" : "uid" }, "domain" : "__DNSDOMAIN__", - "notificationStorageOptions" : { - "dirName" : "__NOTIFICATIONDIR__" - }, - "reloadUrls" : { - "reload.__DNSDOMAIN__" : "http://reload.__DNSDOMAIN__/reload" - }, - "cookieName" : "lemonldap", - "securedCookie" : 0, - "whatToTrace" : "_whatToTrace", - "groups" : {}, - "macros" : { - "_whatToTrace" : "$_auth eq 'SAML' ? \"$_user\\@$_idpConfKey\" : \"$_user\"" - }, - "timeout" : 72000, - "demoExportedVars" : { - "uid" : "uid", - "cn" : "cn", - "mail" : "mail" - }, - "userDB" : "Demo", "exportedHeaders" : { "test1.__DNSDOMAIN__" : { "Auth-User" : "$uid" @@ -148,7 +101,54 @@ "Auth-User" : "$uid" } }, + "exportedVars" : { + "UA" : "HTTP_USER_AGENT" + }, + "globalStorage" : "Apache::Session::File", + "globalStorageOptions" : { + "Directory" : "__SESSIONDIR__", + "LockDirectory" : "__SESSIONDIR__/lock", + "generateModule" : "Lemonldap::NG::Common::Apache::Session::Generate::SHA256" + }, + "groups" : {}, + "locationRules" : { + "manager.__DNSDOMAIN__" : { + "default" : "$uid eq \"dwho\"" + }, + "test1.__DNSDOMAIN__" : { + "^/logout" : "logout_sso", + "default" : "accept" + }, + "test2.__DNSDOMAIN__" : { + "^/logout" : "logout_sso", + "default" : "accept" + } + }, "loginHistoryEnabled" : 1, + "macros" : { + "_whatToTrace" : "$_auth eq 'SAML' ? \"$_user\\@$_idpConfKey\" : \"$_user\"" + }, + "mailUrl" : "http://auth.__DNSDOMAIN__/mail.pl", + "notification" : 1, + "notificationStorage" : "File", + "notificationStorageOptions" : { + "dirName" : "__NOTIFICATIONDIR__" + }, + "passwordDB" : "Demo", + "persistentStorage" : "Apache::Session::File", + "persistentStorageOptions" : { + "Directory" : "__PSESSIONDIR__", + "LockDirectory" : "__PSESSIONDIR__/lock" + }, + "portal" : "http://auth.__DNSDOMAIN__/", + "portalSkinBackground" : "1280px-Cedar_Breaks_National_Monument_partially.jpg", "registerUrl" : "http://auth.__DNSDOMAIN__/register.pl", - "globalStorage" : "Apache::Session::File" + "reloadUrls" : { + "reload.__DNSDOMAIN__" : "http://reload.__DNSDOMAIN__/reload" + }, + "securedCookie" : 0, + "sessionDataToRemember" : {}, + "timeout" : 72000, + "userDB" : "Demo", + "whatToTrace" : "_whatToTrace" } diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm index c446061ff..c0a8d028e 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm @@ -181,7 +181,7 @@ qr/^(?:(?:\-+\s*BEGIN\s+PUBLIC\s+KEY\s*\-+\r?\n)?[a-zA-Z0-9\/\+\r\n]+={0,2}(?:\r 'test' => sub { my $test = grep( { $_ eq $_[0]; } - map( { $$_{'k'}; } @{ $_[2]{'select'}; } ) ); + map( { $_->{'k'}; } @{ $_[2]{'select'}; } ) ); return $test ? 1 : ( 0, "Invalid value '$_[0]' for this select" ); @@ -998,7 +998,7 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0- 'default' => 'ldap://localhost', 'test' => sub { my $l = shift(); - my (@s) = split( /[\s,]+/, $l, 0 ); + my @s = split( /[\s,]+/, $l, 0 ); foreach my $s (@s) { return 0, qq[Bad ldap uri "$s"] unless $s =~ diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build.pm index 0bce42937..6bbf86d47 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build.pm @@ -5,6 +5,7 @@ use Mouse; use Lemonldap::NG::Manager::Build::Attributes; use Lemonldap::NG::Manager::Build::Tree; use Lemonldap::NG::Manager::Build::CTrees; +use Lemonldap::NG::Manager::Conf::Zero; use Data::Dumper; use Regexp::Assemble; use JSON::MaybeXS; @@ -16,6 +17,7 @@ has confTreeFile => ( isa => 'Str', is => 'ro', required => 1 ); has managerConstantsFile => ( isa => 'Str', is => 'ro', required => 1 ); has managerAttributesFile => ( isa => 'Str', is => 'ro', required => 1 ); has defaultValuesFile => ( isa => 'Str', is => 'ro', required => 1 ); +has firstLmConfFile => ( isa => 'Str', is => 'ro', required => 1 ); my @managerAttrKeys = qw(keyTest select type test msgFail default); my $format = 'Creating %-69s: '; @@ -249,6 +251,23 @@ $managerAttr} print F $dst; close F; print STDERR "done\n"; + + $self->buildZeroConf(); +} + +sub buildZeroConf { + my $self = shift; + $jsonEnc->pretty(1); + printf STDERR $format, $self->firstLmConfFile; + open( F, '>', $self->firstLmConfFile ) or die($!); + print F $jsonEnc->encode( + Lemonldap::NG::Manager::Conf::Zero::zeroConf( + '__DNSDOMAIN__', '__SESSIONDIR__', + '__PSESSIONDIR__', '__NOTIFICATIONDIR__' + ) + ); + close F; + print STDERR "done\n"; } sub mydump { @@ -393,6 +412,7 @@ system. managerConstantsFile => "lib/Lemonldap/NG/Manager/Constants.pm", managerAttributesFile => 'lib/Lemonldap/NG/Manager/Attributes.pm', defaultValuesFile => "lib/Lemonldap/NG/Common/Conf/DefaultValues.pm", + firstLmConfFile => "_example/conf/lmConf-1.js", ); =head1 DESCRIPTION diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Zero.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Zero.pm index f8324e1be..75e77dde9 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Zero.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Zero.pm @@ -1,7 +1,7 @@ package Lemonldap::NG::Manager::Conf::Zero; sub zeroConf { - my ($domain, $sessionDir, $notificationDir, $persistentSessionDir) = @_; + my ($domain, $sessionDir, $persistentSessionDir, $notificationDir) = @_; $domain ||= 'example.com'; $sessionDir ||= '/var/lib/lemonldap-ng/sessions'; $persistentSessionDir ||= '/var/lib/lemonldap-ng/psessions'; diff --git a/scripts/jsongenerator.pl b/scripts/jsongenerator.pl index ef922d32e..f38e3680b 100755 --- a/scripts/jsongenerator.pl +++ b/scripts/jsongenerator.pl @@ -8,5 +8,6 @@ Lemonldap::NG::Manager::Build->run( managerConstantsFile => "lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Constants.pm", managerAttributesFile => 'lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm', defaultValuesFile => "lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm", + firstLmConfFile => "_example/conf/lmConf-1.js", );