From 33e7a05f8a52ee4567cc82bb2f3f4eac36aa082d Mon Sep 17 00:00:00 2001 From: Christophe Maudoux Date: Thu, 8 Aug 2019 22:39:09 +0200 Subject: [PATCH] Append parameter to set Manager default route (#1880) --- lemonldap-ng-common/lemonldap-ng.ini | 4 ++++ lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lemonldap-ng-common/lemonldap-ng.ini b/lemonldap-ng-common/lemonldap-ng.ini index 6e352212e..d57e73000 100644 --- a/lemonldap-ng-common/lemonldap-ng.ini +++ b/lemonldap-ng-common/lemonldap-ng.ini @@ -370,6 +370,10 @@ languages = fr, en, it, vi, ar ; The first will be used as default module displayed enabledModules = conf, sessions, notifications, 2ndFA, viewer +; To avoid restricted users to edit configuration, defaulModule MUST be different than 'conf' +; 'viewer' is set by default +;defaultModule = viewer + ; Viewer module allows us to edit configuration in read-only mode ; Options can be set with specific rules like this : ;viewerAllowBrowser = $uid eq 'dwho' diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm index e02962b23..3c8746e5c 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm @@ -17,7 +17,7 @@ use JSON; use Lemonldap::NG::Common::Conf::Constants; use Lemonldap::NG::Common::PSGI::Constants; -our $VERSION = '2.0.5'; +our $VERSION = '2.0.6'; extends 'Lemonldap::NG::Common::Conf::AccessLib', 'Lemonldap::NG::Handler::PSGI::Router'; @@ -52,7 +52,7 @@ sub init { return 0; } - $self->{enabledModules} ||= "conf, sessions, notifications, 2ndFA"; + $self->{enabledModules} ||= "conf, sessions, notifications, 2ndFA, viewer"; my @links; my @enabledModules = map { push @links, $_; "Lemonldap::NG::Manager::" . ucfirst($_) } @@ -87,7 +87,15 @@ sub init { "default-src 'self' $portal;frame-ancestors 'none';form-action 'self';" ); - $self->defaultRoute( $working[0]->defaultRoute ); + # Avoid restricted users to access configuration by default route + my $defaultMod = $self->{defaultModule} || 'viewer'; + my @availableModules = split /[,\s]+/, $self->{enabledModules}; + $self->logger->debug("Default module -> $defaultMod"); + my ($index) = + grep { $availableModules[$_] eq $defaultMod } ( 0 .. $#availableModules ); + $index //= 0; + $self->logger->debug("Default index -> $index"); + $self->defaultRoute( $working[$index]->defaultRoute ); # Find out more glyphicones at https://www.w3schools.com/icons/bootstrap_icons_glyphicons.asp my $linksIcons = {