-
Guillaume ROUSSE authoredGuillaume ROUSSE authored
WebRequest.pm 17.11 KiB
package IdPAccountManager::WebRequest;
use strict;
use warnings;
use CGI;
use English qw(-no_match_vars);
use Template;
use Log::Any::Adapter;
use List::MoreUtils qw(uniq);
use IdPAccountManager::Data::TestAccount;
use IdPAccountManager::Data::AuthenticationToken;
use IdPAccountManager::Data::ServiceProvider;
use IdPAccountManager::SAMLMetadata;
use IdPAccountManager::Tools;
## Defining parameters format
my $urn_or_url_regex = '(http(s?):\/\/|urn:)[^\\\$\*\"\'\`\^\|\<\>\n\s]+'
; ## Format de type URL HTTP ou URN
my $url_regex = 'http(s?):\/\/[^\\\$\*\"\'\`\^\|\<\>\n\s]+';
my $email_regex = '([\w\-\_\.\/\+\=\'\&]+|\".*\")\@[\w\-]+(\.[\w\-]+)+';
my $domains_regex = '[\w\.\-]+(,[\w\.\-]+)*';
my %format = (
## URL
#'attributeauthority' => $url_regex,
'sp_entityid' => $urn_or_url_regex,
);
my %actions = (
select_sp => 'req_select_sp',
account_wizard => 'req_account_wizard',
generate_token => 'req_generate_token',
validate_token => 'req_validate_token',
home => 'req_home',
);
## New web request
sub new {
my ($pkg, %args) = @_;
my $self = {
configuration => $args{configuration},
};
Log::Any::Adapter->set(
'File',
$self->{configuration}->{log_file},
log_level => $self->{configuration}->{log_level}
);
$self->{logger} = Log::Any->get_logger();
IdPAccountManager::DB->register_db(
driver => $self->{configuration}->{database_type},
database => $self->{configuration}->{database_name},
host => $self->{configuration}->{database_host},
password => $self->{configuration}->{database_password},
username => $self->{configuration}->{database_user}
);
$self->{db} = IdPAccountManager::DB->new();
$self->{cgi} = CGI->new();
bless $self, $pkg;
return $self;
}
sub run {