diff --git a/bin/access-check-manager.pl b/bin/access-check-manager.pl index 16018d5cac26addccce2b30f0860082f42660563..03cb467db0de9fe2c12d0a89e2b5135b58abaadd 100755 --- a/bin/access-check-manager.pl +++ b/bin/access-check-manager.pl @@ -15,11 +15,11 @@ use Getopt::Long qw(:config auto_help); use Pod::Usage; use Syntax::Keyword::Try; -use AccountManager::Data::Account; -use AccountManager::Data::Entity; -use AccountManager::Data::Token; -use AccountManager::Metadata; -use AccountManager::Tools; +use AccessCheck::Data::Account; +use AccessCheck::Data::Entity; +use AccessCheck::Data::Token; +use AccessCheck::Metadata; +use AccessCheck::Tools; my %options; GetOptions( @@ -51,7 +51,7 @@ if (!$configuration) { die Config::Tiny->errstr() . "\n"; } -AccountManager::DB->register_db( +AccessCheck::DB->register_db( driver => $configuration->{database}->{type}, database => $configuration->{database}->{name}, host => $configuration->{database}->{host}, @@ -64,7 +64,7 @@ AccountManager::DB->register_db( ] ); -my $db = AccountManager::DB->new(); +my $db = AccessCheck::DB->new(); SWITCH: { if ($action eq 'add_account') { add_account(); last SWITCH; } @@ -96,15 +96,15 @@ sub add_account { my $validity_period = $configuration->{$entity}->{account_validity_period} || $configuration->{service}->{account_validity_period}; - my $password = AccountManager::Tools::generate_password(); + my $password = AccessCheck::Tools::generate_password(); - my $account = AccountManager::Data::Account->new( + my $account = AccessCheck::Data::Account->new( db => $db, profile => $options{profile}, entityid => $options{entityid}, scope => $configuration->{idp}->{scope}, password => $password, - password_hash => AccountManager::Tools::sha256_hash($password), + password_hash => AccessCheck::Tools::sha256_hash($password), creation_date => DateTime->now(), expiration_date => DateTime->now()->add(days => $validity_period) ); @@ -132,7 +132,7 @@ sub list_accounts { } my $accounts = - AccountManager::Data::Account->get_accounts(db => $db, %args); + AccessCheck::Data::Account->get_accounts(db => $db, %args); if (! @$accounts) { printf "No matching test account in DB\n"; @@ -148,12 +148,12 @@ sub list_accounts { } printf "%d accounts removed\n", scalar @$accounts; - $accounts = AccountManager::Data::Account->get_accounts( + $accounts = AccessCheck::Data::Account->get_accounts( db => $db ); try { - AccountManager::Tools::update_ssp_authsources( + AccessCheck::Tools::update_ssp_authsources( $configuration->{setup}->{templates_dir}, $configuration->{setup}->{accounts_file}, $accounts @@ -171,7 +171,7 @@ sub parse_metadata { my $federation_metadata; try { - $federation_metadata = AccountManager::Metadata->new( + $federation_metadata = AccessCheck::Metadata->new( file => $configuration->{setup}->{federation_metadata_file} ); } catch ($error) { @@ -201,7 +201,7 @@ sub add_service { ) unless $options{contacts}; ## Check if entry already exists in DB first - my $provider = AccountManager::Data::Entity->new( + my $provider = AccessCheck::Data::Entity->new( db => $db, entityid => $options{entityid} ); @@ -212,7 +212,7 @@ sub add_service { $provider->contacts($options{contacts}); $provider->displayname($options{displayname}) if $options{displayname}; } else { - $provider = AccountManager::Data::Entity->new( + $provider = AccessCheck::Data::Entity->new( db => $db, entityid => $options{entityid}, contacts => $options{contacts}, @@ -229,7 +229,7 @@ sub add_service { sub list_services { my %args; - my $providers = AccountManager::Data::Entity->get_entities(db => $db, %args); + my $providers = AccessCheck::Data::Entity->get_entities(db => $db, %args); if (! @$providers) { printf "No service provider in DB\n"; @@ -260,7 +260,7 @@ sub list_tokens { push @{ $args{query} }, expiration_date => { lt => DateTime->now() }; } - my $tokens = AccountManager::Data::Token->get_tokens(db => $db, %args); + my $tokens = AccessCheck::Data::Token->get_tokens(db => $db, %args); if (!@$tokens) { printf "No corresponding token found in DB\n"; @@ -287,7 +287,7 @@ sub get_token { $args{token} = $options{token}; } - my $token = AccountManager::Data::Token->new(db => $db, %args); + my $token = AccessCheck::Data::Token->new(db => $db, %args); die "No corresponding token found in DB\n" unless $token->load(); @@ -314,7 +314,7 @@ sub add_token { ) unless $options{entityid}; # delete any previous token for the same email/service couple - my $old_token = AccountManager::Data::Token->new( + my $old_token = AccessCheck::Data::Token->new( db => $db, email_address => $options{email_address}, entityid => $options{entityid} @@ -326,13 +326,13 @@ sub add_token { # compute a new token my $validity_period = $configuration->{service}->{tokens_validity_period}; - my $token = AccountManager::Data::Token->new( + my $token = AccessCheck::Data::Token->new( db => $db, email_address => $options{email_address}, entityid => $options{entityid}, creation_date => DateTime->now(), expiration_date => DateTime->now()->add(hours => $validity_period), - token => AccountManager::Tools::generate_token() + token => AccessCheck::Tools::generate_token() ); $token->save() or die "failed to save authentication token\n"; diff --git a/bin/app b/bin/app index 2e5da3f2861bb8438ed5124a95a07e5a1b7ae1c4..d040273c5f7d1b2211ac07ae17fa9f6d898c7c6d 100755 --- a/bin/app +++ b/bin/app @@ -6,9 +6,9 @@ use warnings; use Mojo::File qw(curfile); use lib curfile()->dirname()->sibling('lib')->to_string; -use AccountManager::App; +use AccessCheck::App; -my $app = AccountManager::App->new( +my $app = AccessCheck::App->new( moniker => 'AccessCheck', ); $app->start(); diff --git a/bin/update-metadata b/bin/update-metadata index 37e79ccfc7d942dcf0af4435ba5a26426bdf5314..ba98806aeb0551459809755d8f42d2fa383cb7fc 100755 --- a/bin/update-metadata +++ b/bin/update-metadata @@ -15,9 +15,9 @@ use Mojo::UserAgent; use Pod::Usage; use Syntax::Keyword::Try; -use AccountManager::Data::DB; -use AccountManager::Data::Entity; -use AccountManager::Metadata; +use AccessCheck::Data::DB; +use AccessCheck::Data::Entity; +use AccessCheck::Metadata; my %options; GetOptions( @@ -41,7 +41,7 @@ die "no database defined in configuration, aborting\n" die "no federation defined in configuration, aborting\n" if !$configuration->{federations}; -AccountManager::Data::DB->register_db( +AccessCheck::Data::DB->register_db( driver => $configuration->{database}->{type}, database => $configuration->{database}->{name}, host => $configuration->{database}->{host}, @@ -54,7 +54,7 @@ AccountManager::Data::DB->register_db( ] ); -my $db = AccountManager::Data::DB->new(); +my $db = AccessCheck::Data::DB->new(); my $ua = Mojo::UserAgent->new( max_redirect => 3 @@ -62,7 +62,7 @@ my $ua = Mojo::UserAgent->new( $db->begin_work(); -AccountManager::Data::Entity->delete_entities(all => 1); +AccessCheck::Data::Entity->delete_entities(all => 1); $db->dbh()->do('ALTER TABLE entities AUTO_INCREMENT = 1'); @@ -84,7 +84,7 @@ foreach my $id (keys %{$configuration->{federations}}) { my $metadata; try { - $metadata = AccountManager::Metadata->new( + $metadata = AccessCheck::Metadata->new( file => $file ); } catch ($error) { @@ -107,7 +107,7 @@ foreach my $id (keys %{$configuration->{federations}}) { my $entity; if ($seen{$entry->{entityid}}++) { - $entity = AccountManager::Data::Entity->new( + $entity = AccessCheck::Data::Entity->new( db => $db, entityid => $entry->{entityid}, ); @@ -117,7 +117,7 @@ foreach my $id (keys %{$configuration->{federations}}) { ); $entity->update(); } else { - $entity = AccountManager::Data::Entity->new( + $entity = AccessCheck::Data::Entity->new( db => $db, type => $entry->{type}, entityid => $entry->{entityid}, diff --git a/lib/AccountManager/App.pm b/lib/AccessCheck/App.pm similarity index 96% rename from lib/AccountManager/App.pm rename to lib/AccessCheck/App.pm index 37d16e73319dd346e7eabf49dfaf8a9ce373a12f..394ad69d23f0279f858ca8fbd081f26c0a6e1b40 100644 --- a/lib/AccountManager/App.pm +++ b/lib/AccessCheck/App.pm @@ -1,4 +1,4 @@ -package AccountManager::App; +package AccessCheck::App; use Mojo::Base qw(Mojolicious); @@ -23,7 +23,7 @@ sub startup { ABSOLUTE => 1, ENCODING => 'utf8', PRE_CHOMP => CHOMP_ONE, - PLUGIN_BASE => 'AccountManager::Template::Plugin', + PLUGIN_BASE => 'AccessCheck::Template::Plugin', } } ); diff --git a/lib/AccountManager/App/Controller.pm b/lib/AccessCheck/App/Controller.pm similarity index 87% rename from lib/AccountManager/App/Controller.pm rename to lib/AccessCheck/App/Controller.pm index 85ffbf53246a1aaeccb4c5cf7c628be1b32c4df1..0688c5b2aeba57768e2b5ce820a09fc656e69ccc 100644 --- a/lib/AccountManager/App/Controller.pm +++ b/lib/AccessCheck/App/Controller.pm @@ -1,15 +1,15 @@ -package AccountManager::App::Controller; +package AccessCheck::App::Controller; use Mojo::Base qw(Mojolicious::Controller); use English qw(-no_match_vars); use Syntax::Keyword::Try; -use AccountManager::Data::DB; -use AccountManager::Data::Entity; -use AccountManager::Data::Token; -use AccountManager::L10N; -use AccountManager::Regexp; +use AccessCheck::Data::DB; +use AccessCheck::Data::Entity; +use AccessCheck::Data::Token; +use AccessCheck::L10N; +use AccessCheck::Regexp; sub init_l10n { my $self = shift; @@ -20,19 +20,19 @@ sub init_l10n { my ($l10n, $lang); if ($self->param('lang')) { $lang = $self->param('lang'); - $l10n = AccountManager::L10N->get_handle($lang); + $l10n = AccessCheck::L10N->get_handle($lang); $log->debug(sprintf("setting language from parameter: %s", $lang)); } elsif ($self->session('lang')) { $lang = $self->session('lang'); - $l10n = AccountManager::L10N->get_handle($lang); + $l10n = AccessCheck::L10N->get_handle($lang); $log->debug(sprintf("setting language from session: %s", $lang)); } elsif ($self->req()->headers->header('Accept-Language')) { - $l10n = AccountManager::L10N->get_handle(); + $l10n = AccessCheck::L10N->get_handle(); $lang = $l10n->language_tag(); $log->debug(sprintf("setting language from Accept-Language header: %s", $lang)); } else { $lang = 'en'; - $l10n = AccountManager::L10N->get_handle($lang); + $l10n = AccessCheck::L10N->get_handle($lang); } $self->session(lang => $lang); @@ -47,7 +47,7 @@ sub init_db { my $config = $self->app()->config(); - AccountManager::Data::DB->register_db( + AccessCheck::Data::DB->register_db( driver => $config->{database}->{type}, database => $config->{database}->{name}, host => $config->{database}->{host}, @@ -58,7 +58,7 @@ sub init_db { my $db; try { - $db = AccountManager::Data::DB->new(); + $db = AccessCheck::Data::DB->new(); } catch { } @@ -108,7 +108,7 @@ sub check_token { my $secret = $args{token}; my $db = $self->stash('db'); - my $token = AccountManager::Data::Token->new( + my $token = AccessCheck::Data::Token->new( db => $db, secret => $secret ); @@ -150,11 +150,11 @@ sub get_sp { return $self->abort( log_message => "Invalid parameter: entityid", user_message => "invalid_entityid" - ) if $entityid !~ $AccountManager::Regexp::entityid; + ) if $entityid !~ $AccessCheck::Regexp::entityid; my $db = $self->stash('db'); - my $sp = AccountManager::Data::Entity->new( + my $sp = AccessCheck::Data::Entity->new( db => $db, entityid => $entityid ); diff --git a/lib/AccountManager/App/Home.pm b/lib/AccessCheck/App/Home.pm similarity index 63% rename from lib/AccountManager/App/Home.pm rename to lib/AccessCheck/App/Home.pm index 40f479ce7cb4c6a21fc78b947b9c92cc5ae893e0..0ef09af0cc954ceb6daea0afbcee8cad5b33045e 100644 --- a/lib/AccountManager/App/Home.pm +++ b/lib/AccessCheck/App/Home.pm @@ -1,14 +1,14 @@ -package AccountManager::App::Home; +package AccessCheck::App::Home; =head1 NAME -AccountManager::App::Home - Home page controller +AccessCheck::App::Home - Home page controller =head1 DESCRIPTION =cut -use Mojo::Base qw(AccountManager::App::Controller); +use Mojo::Base qw(AccessCheck::App::Controller); use English qw(-no_match_vars); use Syntax::Keyword::Try; diff --git a/lib/AccountManager/App/Status.pm b/lib/AccessCheck/App/Status.pm similarity index 88% rename from lib/AccountManager/App/Status.pm rename to lib/AccessCheck/App/Status.pm index 9bb1eafd8f70ea189641a424224a68eb423201af..10d997113a75940a5b324efe8edd1f634f6fad6f 100644 --- a/lib/AccountManager/App/Status.pm +++ b/lib/AccessCheck/App/Status.pm @@ -1,8 +1,8 @@ -package AccountManager::App::Status; +package AccessCheck::App::Status; =head1 NAME -AccountManager::App::Status - Health monitoring controller +AccessCheck::App::Status - Health monitoring controller =head1 DESCRIPTION @@ -12,7 +12,7 @@ Access: restricted by IP address =cut -use Mojo::Base qw(AccountManager::App::Controller); +use Mojo::Base qw(AccessCheck::App::Controller); use English qw(-no_match_vars); use List::MoreUtils qw(none); diff --git a/lib/AccountManager/App/Step1.pm b/lib/AccessCheck/App/Step1.pm similarity index 79% rename from lib/AccountManager/App/Step1.pm rename to lib/AccessCheck/App/Step1.pm index 2aed9e4085658d1aa36849e35a7e28b5dcc28913..826cb20df6e7e310091526c95fc464f60c8a573e 100644 --- a/lib/AccountManager/App/Step1.pm +++ b/lib/AccessCheck/App/Step1.pm @@ -1,11 +1,11 @@ -package AccountManager::App::Step1; +package AccessCheck::App::Step1; -use Mojo::Base qw(AccountManager::App::Controller); +use Mojo::Base qw(AccessCheck::App::Controller); use English qw(-no_match_vars); use Syntax::Keyword::Try; -use AccountManager::Data::Entity; +use AccessCheck::Data::Entity; sub run { my $self = shift; @@ -24,7 +24,7 @@ sub run { my $db = $self->stash('db'); my $user = $self->stash('user'); - my $sps = AccountManager::Data::Entity->get_entities( + my $sps = AccessCheck::Data::Entity->get_entities( db => $db, query => [ type => 'sp', @@ -34,7 +34,7 @@ sub run { my $idp; if ($user) { - my $idps = AccountManager::Data::Entity->get_entities( + my $idps = AccessCheck::Data::Entity->get_entities( db => $db, query => [ type => 'idp', diff --git a/lib/AccountManager/App/Step2.pm b/lib/AccessCheck/App/Step2.pm similarity index 89% rename from lib/AccountManager/App/Step2.pm rename to lib/AccessCheck/App/Step2.pm index 1858923956795a17ee68d4aa4dcc56233b5f45d3..e5749c4eb229db3fe3bc83b366eed5ff06e64bc7 100644 --- a/lib/AccountManager/App/Step2.pm +++ b/lib/AccessCheck/App/Step2.pm @@ -1,6 +1,6 @@ -package AccountManager::App::Step2; +package AccessCheck::App::Step2; -use Mojo::Base qw(AccountManager::App::Controller); +use Mojo::Base qw(AccessCheck::App::Controller); use English qw(-no_match_vars); use Syntax::Keyword::Try; diff --git a/lib/AccountManager/App/Step3.pm b/lib/AccessCheck/App/Step3.pm similarity index 93% rename from lib/AccountManager/App/Step3.pm rename to lib/AccessCheck/App/Step3.pm index d9abe00d6ef03f3f3b024b0b343b56212310af83..8fb5bb130cee91ff1e3b014871293071f0c62325 100644 --- a/lib/AccountManager/App/Step3.pm +++ b/lib/AccessCheck/App/Step3.pm @@ -1,6 +1,6 @@ -package AccountManager::App::Step3; +package AccessCheck::App::Step3; -use Mojo::Base qw(AccountManager::App::Controller); +use Mojo::Base qw(AccessCheck::App::Controller); use DateTime; use Email::MIME; @@ -9,9 +9,9 @@ use English qw(-no_match_vars); use Syntax::Keyword::Try; use Template::Constants qw(:chomp); -use AccountManager::Data::Token; -use AccountManager::Regexp; -use AccountManager::Tools; +use AccessCheck::Data::Token; +use AccessCheck::Regexp; +use AccessCheck::Tools; sub run { my $self = shift; @@ -44,7 +44,7 @@ sub run { return $self->abort( log_message => "Invalid parameter: email", user_message => "invalid_email" - ) if $email !~ $AccountManager::Regexp::email; + ) if $email !~ $AccessCheck::Regexp::email; # override metadata contacts if needed $self->mock_contacts($sp); @@ -56,7 +56,7 @@ sub run { ) if !$sp->is_contact($email); # delete any previous token for the same email/service couple - my $old_token = AccountManager::Data::Token->new( + my $old_token = AccessCheck::Data::Token->new( db => $db, email_address => $email, entityid => $entityid, @@ -76,13 +76,13 @@ sub run { # compute a new token my $validity_period = $config->{service}->{tokens_validity_period}; - my $token = AccountManager::Data::Token->new( + my $token = AccessCheck::Data::Token->new( db => $db, email_address => $email, entityid => $entityid, creation_date => DateTime->now(), expiration_date => DateTime->now()->add(hours => $validity_period), - secret => AccountManager::Tools::generate_secret(20) + secret => AccessCheck::Tools::generate_secret(20) ); try { diff --git a/lib/AccountManager/App/Step4.pm b/lib/AccessCheck/App/Step4.pm similarity index 81% rename from lib/AccountManager/App/Step4.pm rename to lib/AccessCheck/App/Step4.pm index a35f805865281394269d224067062add7193e1f8..932ae9a7183e57450e40b6d1d33a9ad36870d09f 100644 --- a/lib/AccountManager/App/Step4.pm +++ b/lib/AccessCheck/App/Step4.pm @@ -1,6 +1,6 @@ -package AccountManager::App::Step4; +package AccessCheck::App::Step4; -use Mojo::Base qw(AccountManager::App::Controller); +use Mojo::Base qw(AccessCheck::App::Controller); use DateTime; use Email::MIME; @@ -9,9 +9,9 @@ use English qw(-no_match_vars); use Syntax::Keyword::Try; use Template::Constants qw(:chomp); -use AccountManager::Data::Account; -use AccountManager::Data::Token; -use AccountManager::Tools; +use AccessCheck::Data::Account; +use AccessCheck::Data::Token; +use AccessCheck::Tools; sub run { my $self = shift; @@ -51,13 +51,13 @@ sub run { days => $validity ); - my $download_token = AccountManager::Data::Token->new( + my $download_token = AccessCheck::Data::Token->new( db => $db, email_address => $email, entityid => $entityid, creation_date => $creation_date, expiration_date => $token_expiration_date, - secret => AccountManager::Tools::generate_secret(20) + secret => AccessCheck::Tools::generate_secret(20) ); try { @@ -69,18 +69,18 @@ sub run { ); } - my $key = AccountManager::Tools::generate_secret(10); + my $key = AccessCheck::Tools::generate_secret(10); foreach my $profile (@$profiles) { - my $password = AccountManager::Tools::generate_password(10); - my $account = AccountManager::Data::Account->new( + my $password = AccessCheck::Tools::generate_password(10); + my $account = AccessCheck::Data::Account->new( db => $db, profile => $profile, entityid => $entityid, scope => $config->{idp}->{scope}, password => $password, - password_crypt => AccountManager::Tools::encrypt($password, $key), - password_hash => AccountManager::Tools::sha256_hash($password), + password_crypt => AccessCheck::Tools::encrypt($password, $key), + password_hash => AccessCheck::Tools::sha256_hash($password), token => $download_token->secret(), creation_date => $creation_date, expiration_date => $account_expiration_date, @@ -95,10 +95,10 @@ sub run { ) if !@accounts; ## Update simpleSAMLphp configuration to enable test accounts - my $accounts = AccountManager::Data::Account->get_accounts(db => $db); + my $accounts = AccessCheck::Data::Account->get_accounts(db => $db); try { - AccountManager::Tools::update_ssp_authsources( + AccessCheck::Tools::update_ssp_authsources( $self->app()->home()->child('templates'), $config->{setup}->{accounts_file}, $accounts diff --git a/lib/AccountManager/App/Step5.pm b/lib/AccessCheck/App/Step5.pm similarity index 82% rename from lib/AccountManager/App/Step5.pm rename to lib/AccessCheck/App/Step5.pm index 15ecd602dab4ceeff0cc01e7a121240f37b496ff..ba95f1fa34a27f7e2fa64ac17ff80678c4f8e818 100644 --- a/lib/AccountManager/App/Step5.pm +++ b/lib/AccessCheck/App/Step5.pm @@ -1,6 +1,6 @@ -package AccountManager::App::Step5; +package AccessCheck::App::Step5; -use Mojo::Base qw(AccountManager::App::Controller); +use Mojo::Base qw(AccessCheck::App::Controller); use DateTime; use Email::MIME; @@ -9,8 +9,8 @@ use English qw(-no_match_vars); use Syntax::Keyword::Try; use Template::Constants qw(:chomp); -use AccountManager::Data::Account; -use AccountManager::Tools; +use AccessCheck::Data::Account; +use AccessCheck::Tools; sub run { my $self = shift; @@ -35,7 +35,7 @@ sub run { return if !$self->check_token(token => $token, entityid => $entityid); # load accounts from database - my $accounts = AccountManager::Data::Account->get_accounts( + my $accounts = AccessCheck::Data::Account->get_accounts( db => $db, query => [ token => $token @@ -43,7 +43,7 @@ sub run { ); foreach my $account (@$accounts) { - my $password = AccountManager::Tools::decrypt( + my $password = AccessCheck::Tools::decrypt( $account->password_crypt(), $key ); $account->password($password); diff --git a/lib/AccountManager/Data/Account.pm b/lib/AccessCheck/Data/Account.pm similarity index 94% rename from lib/AccountManager/Data/Account.pm rename to lib/AccessCheck/Data/Account.pm index da836d9b5423b8351be470b7b22ba3e7eb6b0275..8056703bb71fdbef50d8bbe8a46cdfe8554b741f 100644 --- a/lib/AccountManager/Data/Account.pm +++ b/lib/AccessCheck/Data/Account.pm @@ -1,6 +1,6 @@ -package AccountManager::Data::Account; +package AccessCheck::Data::Account; -use Mojo::Base 'AccountManager::Data::Object'; +use Mojo::Base 'AccessCheck::Data::Object'; use Rose::DB::Object::Manager; diff --git a/lib/AccountManager/Data/DB.pm b/lib/AccessCheck/Data/DB.pm similarity index 95% rename from lib/AccountManager/Data/DB.pm rename to lib/AccessCheck/Data/DB.pm index 923d43df49625ef366fade4c24df05fc72eff382..3e37a72627e507e78fbd620bf42cbf3801de577d 100644 --- a/lib/AccountManager/Data/DB.pm +++ b/lib/AccessCheck/Data/DB.pm @@ -1,4 +1,4 @@ -package AccountManager::Data::DB; +package AccessCheck::Data::DB; use Mojo::Base 'Rose::DB'; diff --git a/lib/AccountManager/Data/Entity.pm b/lib/AccessCheck/Data/Entity.pm similarity index 94% rename from lib/AccountManager/Data/Entity.pm rename to lib/AccessCheck/Data/Entity.pm index 20c85f77e53ad1d000137e02b13f166df4c61293..8c37ecdff6ee96ee4100be5199d3726099594685 100644 --- a/lib/AccountManager/Data/Entity.pm +++ b/lib/AccessCheck/Data/Entity.pm @@ -1,6 +1,6 @@ -package AccountManager::Data::Entity; +package AccessCheck::Data::Entity; -use Mojo::Base 'AccountManager::Data::Object'; +use Mojo::Base 'AccessCheck::Data::Object'; use List::MoreUtils qw(any); use Rose::DB::Object::Manager; diff --git a/lib/AccessCheck/Data/Object.pm b/lib/AccessCheck/Data/Object.pm new file mode 100644 index 0000000000000000000000000000000000000000..4dbeb759e9e7652fd663255211e8282d6eae4c02 --- /dev/null +++ b/lib/AccessCheck/Data/Object.pm @@ -0,0 +1,11 @@ +package AccessCheck::Data::Object; + +use Mojo::Base 'Rose::DB::Object'; + +use AccessCheck::Data::DB; + +sub init_db { + AccessCheck::Data::DB->new(); +} + +1; diff --git a/lib/AccountManager/Data/Token.pm b/lib/AccessCheck/Data/Token.pm similarity index 93% rename from lib/AccountManager/Data/Token.pm rename to lib/AccessCheck/Data/Token.pm index d4d6f6110e9bf99a4aafe3ac48e683c09a8ac670..3b8dcc38bf3216ecb22cc0c1b5e7dcfcdd1a1e18 100644 --- a/lib/AccountManager/Data/Token.pm +++ b/lib/AccessCheck/Data/Token.pm @@ -1,6 +1,6 @@ -package AccountManager::Data::Token; +package AccessCheck::Data::Token; -use Mojo::Base 'AccountManager::Data::Object'; +use Mojo::Base 'AccessCheck::Data::Object'; use Rose::DB::Object::Manager; diff --git a/lib/AccountManager/L10N.pm b/lib/AccessCheck/L10N.pm similarity index 93% rename from lib/AccountManager/L10N.pm rename to lib/AccessCheck/L10N.pm index e1b75cc1adefa83f36ca9a0ce4e8b4e97be801c5..706eec1b52dda91540a67f2a1f832ff347fa7923 100644 --- a/lib/AccountManager/L10N.pm +++ b/lib/AccessCheck/L10N.pm @@ -1,4 +1,4 @@ -package AccountManager::L10N; +package AccessCheck::L10N; use Mojo::Base 'Locale::Maketext'; diff --git a/lib/AccessCheck/L10N/en.pm b/lib/AccessCheck/L10N/en.pm new file mode 100644 index 0000000000000000000000000000000000000000..d4c05c41ede90bd9e61cfd8e186d23d6243143a9 --- /dev/null +++ b/lib/AccessCheck/L10N/en.pm @@ -0,0 +1,9 @@ +package AccessCheck::L10N::en; + +use Mojo::Base 'AccessCheck::L10N'; + +our %Lexicon = ( + '_AUTO' => 1, +); + +1; diff --git a/lib/AccountManager/L10N/fr.pm b/lib/AccessCheck/L10N/fr.pm similarity index 99% rename from lib/AccountManager/L10N/fr.pm rename to lib/AccessCheck/L10N/fr.pm index 4bbe7b2e05ebab818d9cd9bbddbd3fd6d0463243..7860ec1a01db6f064e0deb9e2fad3470be85b24c 100644 --- a/lib/AccountManager/L10N/fr.pm +++ b/lib/AccessCheck/L10N/fr.pm @@ -1,6 +1,6 @@ -package AccountManager::L10N::fr; +package AccessCheck::L10N::fr; -use Mojo::Base 'AccountManager::L10N'; +use Mojo::Base 'AccessCheck::L10N'; use Locale::Maketext::Lexicon::Gettext; @@ -179,7 +179,7 @@ msgstr "Quelqu'un a demandé la création de comptes de test pour le fournisseur msgid "Test accounts created" msgstr "Comptes de test créés" -#: lib/AccountManager/App.pm:502 +#: lib/AccessCheck/App.pm:502 msgid "Test accounts request" msgstr "Demande de comptes de test" diff --git a/lib/AccountManager/Metadata.pm b/lib/AccessCheck/Metadata.pm similarity index 98% rename from lib/AccountManager/Metadata.pm rename to lib/AccessCheck/Metadata.pm index 6be11388a3f1e1e7913717e9cc280fa3a770f0a1..c12b90e2d8401d8661e986ce57985d8896066a89 100644 --- a/lib/AccountManager/Metadata.pm +++ b/lib/AccessCheck/Metadata.pm @@ -1,4 +1,4 @@ -package AccountManager::Metadata; +package AccessCheck::Metadata; use Mojo::Base -base; @@ -249,7 +249,7 @@ SAMLMetadata - loading SAML federation metadata =head1 SYNOPSIS # instanciate metadata object - my $metadata = AccountManager::SAMLMetadata->new( + my $metadata = AccessCheck::SAMLMetadata->new( file => '/tmp/edugain-saml-metadata.xml' ); @@ -266,7 +266,7 @@ This class parses a SAML2 metadata file. =item new() -Create a new AccountManager::SAMLMetadata object. +Create a new AccessCheck::SAMLMetadata object. Supported arguments include: diff --git a/lib/AccountManager/Regexp.pm b/lib/AccessCheck/Regexp.pm similarity index 89% rename from lib/AccountManager/Regexp.pm rename to lib/AccessCheck/Regexp.pm index 235aa1990374132535a633b0cb56cf33abb8cdf3..7a1d760cdbf4fde3ab98cc589692172a4122925a 100644 --- a/lib/AccountManager/Regexp.pm +++ b/lib/AccessCheck/Regexp.pm @@ -1,4 +1,4 @@ -package AccountManager::Regexp; +package AccessCheck::Regexp; use Mojo::Base -base; diff --git a/lib/AccountManager/Template/Plugin/Quote.pm b/lib/AccessCheck/Template/Plugin/Quote.pm similarity index 88% rename from lib/AccountManager/Template/Plugin/Quote.pm rename to lib/AccessCheck/Template/Plugin/Quote.pm index 61871945874881b986c83ec799727d643408b9dd..78dc81367f1c068627edfc9fd1376b4350aefab6 100644 --- a/lib/AccountManager/Template/Plugin/Quote.pm +++ b/lib/AccessCheck/Template/Plugin/Quote.pm @@ -1,4 +1,4 @@ -package AccountManager::Template::Plugin::Quote; +package AccessCheck::Template::Plugin::Quote; use Mojo::Base -strict; diff --git a/lib/AccountManager/Tools.pm b/lib/AccessCheck/Tools.pm similarity index 94% rename from lib/AccountManager/Tools.pm rename to lib/AccessCheck/Tools.pm index 613273277baaeef46d8f17e995f193b547cf366a..8ae59a876b34de1ebe0590ae64636cc50a85d237 100644 --- a/lib/AccountManager/Tools.pm +++ b/lib/AccessCheck/Tools.pm @@ -1,4 +1,4 @@ -package AccountManager::Tools; +package AccessCheck::Tools; use Mojo::Base -strict; @@ -11,7 +11,7 @@ use MIME::Base64; use Template; use Template::Constants qw(:chomp); -use AccountManager::Template::Plugin::Quote; +use AccessCheck::Template::Plugin::Quote; sub encrypt { my ($string, $key) = @_; @@ -118,7 +118,7 @@ __END__ =head1 NAME -AccountManager::Tools - Set of subroutines usefull for the Test Account manager +AccessCheck::Tools - Set of subroutines usefull for the Test Account manager =head1 DESCRIPTION diff --git a/lib/AccountManager/Data/Object.pm b/lib/AccountManager/Data/Object.pm deleted file mode 100644 index d39b28adae7f94995fe950e576baa94257d212e4..0000000000000000000000000000000000000000 --- a/lib/AccountManager/Data/Object.pm +++ /dev/null @@ -1,11 +0,0 @@ -package AccountManager::Data::Object; - -use Mojo::Base 'Rose::DB::Object'; - -use AccountManager::Data::DB; - -sub init_db { - AccountManager::Data::DB->new(); -} - -1; diff --git a/lib/AccountManager/L10N/en.pm b/lib/AccountManager/L10N/en.pm deleted file mode 100644 index e872834b2595c1cb8b8ef7b62599d2479fca1fbb..0000000000000000000000000000000000000000 --- a/lib/AccountManager/L10N/en.pm +++ /dev/null @@ -1,9 +0,0 @@ -package AccountManager::L10N::en; - -use Mojo::Base 'AccountManager::L10N'; - -our %Lexicon = ( - '_AUTO' => 1, -); - -1; diff --git a/lib/Makefile.am b/lib/Makefile.am index e3c98dd0b92380d91b1af4941783febc413ff6b7..cce6d0dde611c0b213abba397205aa6dc1034163 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,26 +1,26 @@ applibdir = $(pkgdatadir)/lib nobase_applib_DATA = \ - AccountManager/Data/Account.pm \ - AccountManager/Data/DB.pm \ - AccountManager/Data/Entity.pm \ - AccountManager/Data/Object.pm \ - AccountManager/Data/Token.pm \ - AccountManager/Metadata.pm \ - AccountManager/Regexp.pm \ - AccountManager/Tools.pm \ - AccountManager/L10N.pm \ - AccountManager/L10N/en.pm \ - AccountManager/L10N/fr.pm \ - AccountManager/App.pm \ - AccountManager/App/Home.pm \ - AccountManager/App/Controller.pm \ - AccountManager/App/Status.pm \ - AccountManager/App/Step1.pm \ - AccountManager/App/Step2.pm \ - AccountManager/App/Step3.pm \ - AccountManager/App/Step4.pm \ - AccountManager/App/Step5.pm \ - AccountManager/Template/Plugin/Quote.pm + AccessCheck/Data/Account.pm \ + AccessCheck/Data/DB.pm \ + AccessCheck/Data/Entity.pm \ + AccessCheck/Data/Object.pm \ + AccessCheck/Data/Token.pm \ + AccessCheck/Metadata.pm \ + AccessCheck/Regexp.pm \ + AccessCheck/Tools.pm \ + AccessCheck/L10N.pm \ + AccessCheck/L10N/en.pm \ + AccessCheck/L10N/fr.pm \ + AccessCheck/App.pm \ + AccessCheck/App/Home.pm \ + AccessCheck/App/Controller.pm \ + AccessCheck/App/Status.pm \ + AccessCheck/App/Step1.pm \ + AccessCheck/App/Step2.pm \ + AccessCheck/App/Step3.pm \ + AccessCheck/App/Step4.pm \ + AccessCheck/App/Step5.pm \ + AccessCheck/Template/Plugin/Quote.pm EXTRA_DIST = $(nobase_applib_DATA) diff --git a/t/app.t b/t/app.t index c8240dc2fc64b6ab199580dff8998c604817e638..9433c3c5eeb2d95c8b1ba275a792b880afd6019f 100755 --- a/t/app.t +++ b/t/app.t @@ -12,8 +12,8 @@ use Test::HTML::Tidy5 qw(); use Test::More; use Test::Mojo::WithRoles 'SubmitForm'; -use AccountManager::Data::DB; -use AccountManager::Data::Entity; +use AccessCheck::Data::DB; +use AccessCheck::Data::Entity; plan(skip_all => 'live database required') unless $ENV{TEST_DB_HOST} && @@ -46,16 +46,16 @@ sub setup { system("mysql --host=$host --user=$username --password=$password $name < conf/manager.sql") == 0 or die "can't run mysql: $CHILD_ERROR\n"; - AccountManager::Data::DB->register_db( + AccessCheck::Data::DB->register_db( driver => $args{type}, host => $host, database => $name, password => $password, username => $username, ); - my $db = AccountManager::Data::DB->new(); + my $db = AccessCheck::Data::DB->new(); - my $entity = AccountManager::Data::Entity->new( + my $entity = AccessCheck::Data::Entity->new( db => $db, type => 'sp', entityid => 'https://sp.renater.fr/', @@ -111,7 +111,7 @@ EOF sub get_test_object { my %args = @_; - my $app = $args{app} || 'AccountManager::App'; + my $app = $args{app} || 'AccessCheck::App'; my $t = Test::Mojo::WithRoles->new($app); my $ua = $t->ua(); diff --git a/t/metadata.t b/t/metadata.t index 3017c603cc42fc39e2988c2383e0207ee6012e82..0f1e45eaabeaff2cd716736993c41109f6e640e5 100755 --- a/t/metadata.t +++ b/t/metadata.t @@ -8,19 +8,19 @@ use File::Temp; use Test::More; use Test::Exception; -use AccountManager::Metadata; +use AccessCheck::Metadata; plan tests => 22; my $metadata; throws_ok { - $metadata = AccountManager::Metadata->new(); + $metadata = AccessCheck::Metadata->new(); } qr/^missing argument 'file'/, 'instanciation: no file argument'; throws_ok { - $metadata = AccountManager::Metadata->new( + $metadata = AccessCheck::Metadata->new( file => '/no/such/file', ); } qr/^non-existing file/, @@ -31,7 +31,7 @@ my $file1 = File::Temp->new(UNLINK => $ENV{TEST_DEBUG} ? 0 : 1); chmod 0000, $file1; throws_ok { - $metadata = AccountManager::Metadata->new( + $metadata = AccessCheck::Metadata->new( file => $file1->filename() ); } qr/^non-readable file/, @@ -40,7 +40,7 @@ throws_ok { chmod 0644, $file1; throws_ok { - $metadata = AccountManager::Metadata->new( + $metadata = AccessCheck::Metadata->new( file => $file1->filename() ); } qr/^Failed to parse file: \S+ parser error : Document is empty/, @@ -54,7 +54,7 @@ EOF close($file2); throws_ok { - $metadata = AccountManager::Metadata->new( + $metadata = AccessCheck::Metadata->new( file => $file2->filename() ); } qr/^Failed to parse file: \S+ parser error : Start tag expected/, @@ -69,14 +69,14 @@ EOF close($file3); throws_ok { - $metadata = AccountManager::Metadata->new( + $metadata = AccessCheck::Metadata->new( file => $file3->filename() ); } qr/^incorrect root element type 'root'/, 'instanciation: incorrect xml file'; lives_ok { - $metadata = AccountManager::Metadata->new( + $metadata = AccessCheck::Metadata->new( file => 't/edugain.xml' ); } 'instanciation: edugain metadata'; diff --git a/t/tools.t b/t/tools.t index 8452f7338bc516fcafbee0cc17d1953550c3ea69..7a53faad58cd879eb8d1d0cb87a48f8217458327 100755 --- a/t/tools.t +++ b/t/tools.t @@ -6,22 +6,22 @@ use warnings; use English qw(-no_match_vars); use Test::More; -use AccountManager::Tools; +use AccessCheck::Tools; plan tests => 5; -my $key = AccountManager::Tools::generate_secret(10); -my $password = AccountManager::Tools::generate_password(10); +my $key = AccessCheck::Tools::generate_secret(10); +my $password = AccessCheck::Tools::generate_password(10); ok(length($password) == 10, 'password has expected size'); ok(length($key) == 10, 'key has expected size'); ok($key ne $password, 'key and passwords are random strings'); -my $encrypted_password = AccountManager::Tools::encrypt($password, $key); +my $encrypted_password = AccessCheck::Tools::encrypt($password, $key); ok($encrypted_password ne $password, 'encrypted password differs from password'); -my $decrypted_password = AccountManager::Tools::decrypt($encrypted_password, $key); +my $decrypted_password = AccessCheck::Tools::decrypt($encrypted_password, $key); ok($decrypted_password eq $password, 'decrypted password matches password');