From accd73fde993b6e479b2796b318bdeea1328c10b Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Fri, 24 Nov 2017 16:01:39 +0100 Subject: [PATCH] use a default service section --- bin/account-manager.pl.in | 2 +- conf/manager.conf.in | 19 ++++++++----------- lib/IdPAccountManager/WebRequest.pm | 14 +++++++------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/bin/account-manager.pl.in b/bin/account-manager.pl.in index 4a06378..92a6e29 100755 --- a/bin/account-manager.pl.in +++ b/bin/account-manager.pl.in @@ -98,7 +98,7 @@ sub add_account { die "Failed to save test account\n" unless $test_account->save( - accounts_validity_period => $configuration->{_}->{accounts_validity_period} + accounts_validity_period => $configuration->{service}->{account_validity_period} ); printf "Account created:\n\tuserid: user%d\n\tpassword: %s\n", diff --git a/conf/manager.conf.in b/conf/manager.conf.in index 6f96ecc..d81efe0 100644 --- a/conf/manager.conf.in +++ b/conf/manager.conf.in @@ -1,27 +1,16 @@ -# Validity period of test accounts, in days -accounts_validity_period = 7 - # Token validity period, in hours tokens_validity_period = 2 # Templates directory templates_dir = @templatesdir@ -# Development feature -# hard-coded list of contactPersons -# these email addresses will be added to the list of contacts for any SP -dev_sp_contact = john@my.fqdn, sarah@my.fqdn - # From field use by the account manager notice_from = edugain-access-check.fqdn # federation metadata local copy path federation_metadata_file = @sysconfdir@/edugain-md.xml -# Valid account profiles -account_profiles = fullset1, limitedset1, generic1, student1, student2, teacher1, teacher2, alumni1, librarywalkin1, employee1, researcher1 - # Path to sendmail executable sendmail_path = /usr/sbin/sendmail @@ -47,3 +36,11 @@ scope = my.fqdn entityid = https://my.fqdn/simplesaml/saml2/idp/metadata.php displayname = eduGAIN Access Check accounts_file = @sysconfdir@/accounts.php + +[service] +# validity period of test accounts, in days +account_validity_period = 7 +# valid account profiles +account_profiles = fullset1, limitedset1, generic1, student1, student2, teacher1, teacher2, alumni1, librarywalkin1, employee1, researcher1 +# override contacts defined in metadata if defined +contacts = john@my.fqdn, sarah@my.fqdn diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm index 502495d..e10acc6 100644 --- a/lib/IdPAccountManager/WebRequest.pm +++ b/lib/IdPAccountManager/WebRequest.pm @@ -126,7 +126,7 @@ sub execute { SCRIPT_NAME => $ENV{SCRIPT_NAME} }, conf => { - accounts_validity_period => $self->{configuration}->{accounts_validity_period}, + accounts_validity_period => $self->{configuration}->{service}->{account_validity_period}, app_name => $self->{configuration}->{app}->{name}, app_url => $self->{configuration}->{app}->{url}, idp_scope => $self->{configuration}->{idp}->{scope}, @@ -258,10 +258,10 @@ sub req_select_sp { } } - if ($self->{configuration}->{_}->{dev_sp_contact}) { + if ($self->{configuration}->{service}->{contacts}) { # replace SP contacts $provider->contacts( - split(/, */, $self->{configuration}->{_}->{dev_sp_contact}) + split(/, */, $self->{configuration}->{service}->{contacts}) ); } @@ -299,10 +299,10 @@ sub req_generate_token { return; } - if ($self->{configuration}->{_}->{dev_sp_contact}) { + if ($self->{configuration}->{service}->{contacts}) { # replace SP contacts $provider->contacts( - split(/, */, $self->{configuration}->{_}->{dev_sp_contact}) + split(/, */, $self->{configuration}->{service}->{contacts}) ); } @@ -464,7 +464,7 @@ sub req_validate_token { ## create test accounts my @accounts; - foreach my $profile (split(/, */, $self->{configuration}->{_}->{account_profiles})) { + foreach my $profile (split(/, */, $self->{configuration}->{service}->{account_profiles})) { my $account = IdPAccountManager::TestAccount->new( db => $self->{db}, profile => $profile, @@ -473,7 +473,7 @@ sub req_validate_token { ); next unless $account; next unless $account->save( - accounts_validity_period => $self->{configuration}->{_}->{accounts_validity_period} + accounts_validity_period => $self->{configuration}->{service}->{account_validity_period} ); push @accounts, $account; } -- GitLab