From 7e950cfb448d959fe4440fc053f8464caee460fb Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Tue, 14 Nov 2017 10:49:20 +0100 Subject: [PATCH] make scope a persistent attribute --- bin/account-manager.pl.in | 4 ++-- conf/create-manager-db.sql | 1 + lib/IdPAccountManager/TestAccount.pm | 20 +++++++------------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/bin/account-manager.pl.in b/bin/account-manager.pl.in index 14f7124..050feba 100755 --- a/bin/account-manager.pl.in +++ b/bin/account-manager.pl.in @@ -91,7 +91,8 @@ sub add_account { my $test_account = IdPAccountManager::TestAccount->new( db => $db, profile => $options{account_profile}, - sp_entityid => $options{sp_entityid} + sp_entityid => $options{sp_entityid}, + scope => $configuration->{idp_scope}, ); die "Failed to create test account\n" @@ -147,7 +148,6 @@ sub list_accounts { IdPAccountManager::Tools::update_ssp_authsources( $configuration->{templates_dir}, $configuration->{idp_accounts_file}, - $configuration->{idp_scope}, $accounts ); }; diff --git a/conf/create-manager-db.sql b/conf/create-manager-db.sql index 9ceaa29..98fc34e 100644 --- a/conf/create-manager-db.sql +++ b/conf/create-manager-db.sql @@ -33,6 +33,7 @@ CREATE TABLE `testaccounts` ( `creation_date` int(11) DEFAULT NULL, `expiration_date` int(11) DEFAULT NULL, `profile` varchar(100) NOT NULL, + `scope` varchar(100) NOT NULL, `sp_entityid` varchar(250) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/lib/IdPAccountManager/TestAccount.pm b/lib/IdPAccountManager/TestAccount.pm index 0164cfe..824f14c 100644 --- a/lib/IdPAccountManager/TestAccount.pm +++ b/lib/IdPAccountManager/TestAccount.pm @@ -16,6 +16,7 @@ __PACKAGE__->meta->setup( creation_date => { type => 'integer' }, expiration_date => { type => 'integer' }, profile => { type => 'varchar', length => 100, not_null => 1 }, + scope => { type => 'varchar', length => 100, not_null => 1 }, sp_entityid => { type => 'varchar', length => 250, not_null => 1 }, ], @@ -114,9 +115,12 @@ sub print { $fd = \*STDOUT unless $fd; printf $fd -"Account ID=%s; password_hash=%s; sp_entityid=%s; profile=%s; creation_date=%s; expiration_date=%s\n", - $self->id(), $self->password_hash(), - $self->sp_entityid(), $self->profile(), +"Account ID=%s; password_hash=%s; sp_entityid=%s; profile=%s; scope=%s; creation_date=%s; expiration_date=%s\n", + $self->id(), + $self->password_hash(), + $self->sp_entityid(), + $self->profile(), + $self->scope(), POSIX::strftime('%Y:%m:%d', localtime($self->creation_date())), POSIX::strftime('%Y:%m:%d', localtime($self->expiration_date())); } @@ -144,16 +148,6 @@ sub save { $self->SUPER::save(); } -sub scope { - my ($self, $scope) = @_; - - if ($scope) { - $self->{scope} = $scope; - } else { - return $self->{scope}; - } -} - sub internal_uid { my ($self) = @_; return 'user' . $self->id(); -- GitLab