Skip to content
Snippets Groups Projects
Commit 29fd0528 authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

namespace change: AccountManager -> AccessCheck

parent fbf014cf
No related branches found
No related tags found
No related merge requests found
Showing
with 123 additions and 103 deletions
......@@ -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";
......
......@@ -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();
......@@ -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},
......
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',
}
}
);
......
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
);
......
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;
......
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);
......
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',
......
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;
......
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 {
......
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
......
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);
......
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;
......
package AccountManager::Data::DB;
package AccessCheck::Data::DB;
use Mojo::Base 'Rose::DB';
......
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;
......
package AccountManager::Data::Object;
package AccessCheck::Data::Object;
use Mojo::Base 'Rose::DB::Object';
use AccountManager::Data::DB;
use AccessCheck::Data::DB;
sub init_db {
AccountManager::Data::DB->new();
AccessCheck::Data::DB->new();
}
1;
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;
......
package AccountManager::L10N;
package AccessCheck::L10N;
use Mojo::Base 'Locale::Maketext';
......
package AccountManager::L10N::en;
package AccessCheck::L10N::en;
use Mojo::Base 'AccountManager::L10N';
use Mojo::Base 'AccessCheck::L10N';
our %Lexicon = (
'_AUTO' => 1,
......
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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment