From 08c1f579e13578e461f9e14fc7abcb61c23b7d55 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Fri, 2 Mar 2018 12:17:04 +0100
Subject: [PATCH] use same configuration directives as the registry

---
 bin/account-manager.pl.in |  6 +++---
 conf/manager.conf.in      | 11 ++++++-----
 lib/AccountManager/App.pm | 10 +++++-----
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/bin/account-manager.pl.in b/bin/account-manager.pl.in
index a235c1b..729f12d 100755
--- a/bin/account-manager.pl.in
+++ b/bin/account-manager.pl.in
@@ -152,7 +152,7 @@ sub list_accounts {
 
         eval {
             AccountManager::Tools::update_ssp_authsources(
-                $configuration->{_}->{templates_dir},
+                $configuration->{setup}->{templates_dir},
                 $configuration->{idp}->{accounts_file},
                 $accounts
             );
@@ -170,7 +170,7 @@ sub parse_metadata {
 
     eval {
         $federation_metadata = AccountManager::Metadata->new(
-            file => $configuration->{_}->{federation_metadata_file}
+            file => $configuration->{setup}->{federation_metadata_file}
         );
     };
     die "unable to load federation metadata: $EVAL_ERROR" if $EVAL_ERROR;
@@ -178,7 +178,7 @@ sub parse_metadata {
     my $data = $federation_metadata->parse(id => $options{sp_entityid});
 
     printf "Document %s parsed\n",
-      $configuration->{_}->{federation_metadata_file};
+      $configuration->{setup}->{federation_metadata_file};
 
     ## List SAML entities
     printf "Hashref representing the metadata:\n";
diff --git a/conf/manager.conf.in b/conf/manager.conf.in
index 3add16e..bdfcdab 100644
--- a/conf/manager.conf.in
+++ b/conf/manager.conf.in
@@ -2,17 +2,18 @@
 # Token validity period, in hours
 tokens_validity_period = 2
 
-# Templates directory
-templates_dir = @templatesdir@
-
-# federation metadata local copy path
-federation_metadata_file = @sysconfdir@/edugain-md.xml
 
 [app]
 version = open Beta 1
 url = https://my.fqdn/accountmanager
 support_email = support@my.fqdn
 
+[setup]
+# templates directory
+templates_dir = @templatesdir@
+# federation metadata local copy path
+federation_metadata_file = @sysconfdir@/edugain-md.xml
+
 [logger]
 file = /opt/testidp/IdPAccountManager/log/manager.log
 level = info
diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index 26d5fec..65078b1 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -133,7 +133,7 @@ sub respond {
     ## Parse template
     my $tt2 = Template->new({
         ENCODING => 'utf8',
-        INCLUDE_PATH => $self->{configuration}->{_}->{templates_dir} . "/web/$lang"
+        INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/web/$lang"
     });
 
     $self->{logger}->debug("Responding with outer template '$in{template}' and inner template '$in{data}->{content}'");
@@ -160,7 +160,7 @@ sub req_select_sp {
 
     eval {
         $metadata = AccountManager::Metadata->new(
-            file => $self->{configuration}->{_}->{federation_metadata_file}
+            file => $self->{configuration}->{setup}->{federation_metadata_file}
         );
     };
     if ($EVAL_ERROR) {
@@ -225,7 +225,7 @@ sub req_select_email {
 
         eval {
             $metadata = AccountManager::Metadata->new(
-                file => $self->{configuration}->{_}->{federation_metadata_file}
+                file => $self->{configuration}->{setup}->{federation_metadata_file}
             );
         };
         if ($EVAL_ERROR) {
@@ -434,7 +434,7 @@ sub req_complete_challenge {
 
     my $tt2 = Template->new({
         ENCODING => 'utf8',
-        INCLUDE_PATH => $self->{configuration}->{_}->{templates_dir} . "/mail/$lang"
+        INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/mail/$lang"
     });
     my $template = 'send_authentication_token.tt2.eml';
     my $data = {
@@ -632,7 +632,7 @@ sub req_create_accounts {
 
     eval {
         AccountManager::Tools::update_ssp_authsources(
-            $self->{configuration}->{_}->{templates_dir},
+            $self->{configuration}->{setup}->{templates_dir},
             $self->{configuration}->{idp}->{accounts_file},
             $accounts
         );
-- 
GitLab