From 24488698add7f9d19554b805cbaa44417ab766af Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Fri, 10 Nov 2017 18:13:40 +0100 Subject: [PATCH] use shorter fields names --- bin/account-manager.pl.in | 8 ++-- conf/create-manager-db.sql | 4 +- lib/IdPAccountManager/TestAccount.pm | 42 +++++++++---------- lib/IdPAccountManager/WebRequest.pm | 8 ++-- .../accountProfiles/valid-accounts.php.tt2 | 2 +- templates/web/validate_token.tt2.html | 4 +- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/bin/account-manager.pl.in b/bin/account-manager.pl.in index e06a1bf..14f7124 100755 --- a/bin/account-manager.pl.in +++ b/bin/account-manager.pl.in @@ -89,9 +89,9 @@ sub add_account { ) unless $options{sp_entityid}; my $test_account = IdPAccountManager::TestAccount->new( - db => $db, - account_profile => $options{account_profile}, - sp_entityid => $options{sp_entityid} + db => $db, + profile => $options{account_profile}, + sp_entityid => $options{sp_entityid} ); die "Failed to create test account\n" @@ -114,7 +114,7 @@ sub list_accounts { } if ($options{account_profile}) { - push @{ $args{query} }, account_profile => $options{account_profile}; + push @{ $args{query} }, profile => $options{account_profile}; } if ($options{filter_expired}) { diff --git a/conf/create-manager-db.sql b/conf/create-manager-db.sql index 0618719..9ceaa29 100644 --- a/conf/create-manager-db.sql +++ b/conf/create-manager-db.sql @@ -29,10 +29,10 @@ CREATE TABLE `serviceproviders` ( CREATE TABLE `testaccounts` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, - `user_password_hash` varchar(50) NOT NULL, + `password_hash` varchar(50) NOT NULL, `creation_date` int(11) DEFAULT NULL, `expiration_date` int(11) DEFAULT NULL, - `account_profile` varchar(100) NOT NULL, + `profile` 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 1003333..0164cfe 100644 --- a/lib/IdPAccountManager/TestAccount.pm +++ b/lib/IdPAccountManager/TestAccount.pm @@ -11,12 +11,12 @@ __PACKAGE__->meta->setup( table => 'testaccounts', columns => [ - id => { type => 'bigserial', not_null => 1 }, - user_password_hash => { type => 'varchar', length => 50, not_null => 1 }, - creation_date => { type => 'integer' }, - expiration_date => { type => 'integer' }, - account_profile => { type => 'varchar', length => 100, not_null => 1 }, - sp_entityid => { type => 'varchar', length => 250, not_null => 1 }, + id => { type => 'bigserial', not_null => 1 }, + password_hash => { type => 'varchar', length => 50, not_null => 1 }, + creation_date => { type => 'integer' }, + expiration_date => { type => 'integer' }, + profile => { type => 'varchar', length => 100, not_null => 1 }, + sp_entityid => { type => 'varchar', length => 250, not_null => 1 }, ], primary_key_columns => [ 'id' ], @@ -114,17 +114,17 @@ sub print { $fd = \*STDOUT unless $fd; printf $fd -"Account ID=%s; password_hash=%s; sp_entityid=%s; account_profile=%s; creation_date=%s; expiration_date=%s\n", - $self->id(), $self->user_password_hash(), - $self->sp_entityid(), $self->account_profile(), +"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(), POSIX::strftime('%Y:%m:%d', localtime($self->creation_date())), POSIX::strftime('%Y:%m:%d', localtime($self->expiration_date())); } -sub user_password { +sub password { my ($self) = @_; - return $self->{user_password}; + return $self->{password}; } sub save { @@ -132,10 +132,10 @@ sub save { # If no ID is defined, it is a new account if (! defined $self->id()) { - $self->{user_password} = + $self->{password} = IdPAccountManager::Tools::generate_password(); - $self->user_password_hash( - IdPAccountManager::Tools::sha256_hash($self->{user_password})); + $self->password_hash( + IdPAccountManager::Tools::sha256_hash($self->{password})); $self->creation_date(time); $self->expiration_date( time + ($args{accounts_validity_period} * 3600 * 24)); @@ -161,34 +161,34 @@ sub internal_uid { sub cn { my ($self) = @_; - return $cn{$self->account_profile()}; + return $cn{$self->profile()}; } sub displayName { my ($self) = @_; - return $cn{$self->account_profile()}; + return $cn{$self->profile()}; } sub givenName { my ($self) = @_; - return $givenName{$self->account_profile()}; + return $givenName{$self->profile()}; } sub mail { my ($self) = @_; - my $prefix = $mail{$self->account_profile()}; + my $prefix = $mail{$self->profile()}; return $prefix ? $prefix . '@' . $self->{scope} : undef; } sub eduPersonAffiliation { my ($self) = @_; - return $affiliation{$self->account_profile()}; + return $affiliation{$self->profile()}; } sub eduPersonScopedAffiliation { my ($self) = @_; - my $affiliations = $scopedAffiliation{$self->account_profile()}; + my $affiliations = $scopedAffiliation{$self->profile()}; return $affiliations ? [ map { $_ . '@' . $self->{scope} } @$affiliations ] : undef; } @@ -210,7 +210,7 @@ sub schacHomeOrganizationType { sub comment { my ($self) = @_; - return $comment{$self->account_profile()}; + return $comment{$self->profile()}; } 1; diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm index 1b82d34..b6eb468 100755 --- a/lib/IdPAccountManager/WebRequest.pm +++ b/lib/IdPAccountManager/WebRequest.pm @@ -466,10 +466,10 @@ sub req_validate_token { foreach my $profile (split(/, */, $self->{configuration}->{account_profiles})) { my $account = IdPAccountManager::TestAccount->new( - db => $self->{db}, - account_profile => $profile, - sp_entityid => $self->{in}->{sp_entityid}, - scope => $self->{configuration}->{idp_scope}, + db => $self->{db}, + profile => $profile, + sp_entityid => $self->{in}->{sp_entityid}, + scope => $self->{configuration}->{idp_scope}, ); next unless $account; next unless $account->save( diff --git a/templates/accountProfiles/valid-accounts.php.tt2 b/templates/accountProfiles/valid-accounts.php.tt2 index c9f145a..6b9d15e 100644 --- a/templates/accountProfiles/valid-accounts.php.tt2 +++ b/templates/accountProfiles/valid-accounts.php.tt2 @@ -19,7 +19,7 @@ $validTestAccounts = array ( 'authcrypt:Hash', [% FOREACH account IN accounts -%] - 'user[% account.id() %]:{SHA256}[% account.user_password_hash() %]=' => array( + 'user[% account.id() %]:{SHA256}[% account.password_hash() %]=' => array( [% print_attribute(account, 'internal_uid') -%] [% print_attribute(account, 'cn') -%] [% print_attribute(account, 'displayName') -%] diff --git a/templates/web/validate_token.tt2.html b/templates/web/validate_token.tt2.html index 3088358..36ca149 100644 --- a/templates/web/validate_token.tt2.html +++ b/templates/web/validate_token.tt2.html @@ -19,12 +19,12 @@ [% FOREACH account IN accounts %] <div class="tbl"> <table> - <caption>Account profile: [% account.account_profile() %]</caption> + <caption>Account profile: [% account.profile() %]</caption> <tr> <th>user name:</th><td> user[% account.id() %]</td> </tr> <tr> - <th>user password:</th><td>[% account.user_password() %]</td> + <th>user password:</th><td>[% account.password() %]</td> </tr> <tr> <td colspan="2"><strong>comment:</strong><div><p>[% account.comment() %]</p></div></td> -- GitLab