#!/usr/bin/perl
use strict;
use Config::Tiny;
use LIMS::Local::Utils;
my $path_to_app_root = LIMS::Local::Utils::find_home
|| die "Couldn't find path to application directory"; # warn $path_to_app_root;
############ configurable settings in settings.txt #####################
my $config = Config::Tiny->read("$path_to_app_root/config/settings.txt");
my %settings = map %{ $config->{$_} }, qw(local global); # warn Data::Dumper::Dumper \%settings;
########################################################################
my %dbh_params = (
driver => 'mysql',
db => $settings{development_db}, # default to devel db - overridden in mod_perl config
userid => $settings{db_user_id},
pwd => $settings{db_password},
);
my %cfg = (
settings => \%settings,
authen_cfg => { # CAP::Authentication
DRIVER => [ ], # defined in cgiapp_init()
LOGIN_SESSION_TIMEOUT => {
# IDLE_FOR => '1m', # dealt with under CUSTOM:
EVERY => '1d',
CUSTOM => sub {
# This value can be set to a subroutine reference that returns true
# if the session should be timed out, and false if it is still active.
my $authen = shift; # have access to UserProfile in $authen, but how to get it out??
return ( $authen->username ne 'ADMIN' &&
( time() - $authen->last_access ) > $settings{admin_timeout} ); # return 1 if true
# warn $authen->{'cgiapp'}{'UserProfile'}{'designation'};
# warn Dumper('last_access: ' . $authen->last_access); # warn 'time: ' . time();
# warn sprintf "authen_cfg, time - last_access = %s [returned %s]",
# (time() - $authen->last_access), (time() - $authen->last_access > 1800 ? 1 : 0);
# $authen->username = users.username; use time in seconds as eg > '30m' does not work:
},
},
LOGIN_RUNMODE => 'login', # redirect_after_login requires destination field in .tt if used
# LOGIN_URL => '/hmds/login', # causes redirection loop & don't need if using LOGIN_RUNMODE
# POST_LOGIN_URL => '', # leave these blank to re-direct to original requested page
# POST_LOGIN_RUNMODE => '', # will override POST_LOGIN_URL
STORE => 'Session',
# STORE => [
# 'Cookie',
# NAME => 'HILISAuthentication',
# SECRET => 'HILIS4',
# EXPIRY => '30m',
# ],
},
db => {
production => $settings{production_db},
development => $settings{development_db},
},
dbh_params => [
"dbi:$dbh_params{driver}:$dbh_params{db}",
$dbh_params{userid},
$dbh_params{pwd},
],
dfv_defaults => {
missing_optional_valid => 1,
filters => 'trim', # trims white space pre/post field param
field_filters => { }, # use for forcing field formats eg foo => 'uc'
msgs => {
any_errors => 'dfv_errors', # default err__
# invalid_separator => '
', # needs to be in own