From 01f3c1a2936774534e34752c769584f8778899ef Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Mon, 21 Oct 2013 10:17:08 -0600 Subject: [PATCH] [PASSED QA] BUG8446, Follow up: Remove unnecessary sysprefs, move to config Signed-off-by: Martin Renvoize Signed-off-by: Matthias Meusburger Signed-off-by: Katrin Fischer --- C4/Auth.pm | 11 +++-------- C4/Auth_with_Shibboleth.pm | 11 ++++++++--- installer/data/mysql/updatedatabase.pl | 8 -------- .../prog/en/modules/admin/preferences/admin.pref | 11 ----------- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt | 16 ++++++++++++++++ koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt | 2 +- koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt | 6 +++--- koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt | 3 +-- opac/opac-main.pl | 3 +-- opac/opac-user.pl | 3 +-- 10 files changed, 34 insertions(+), 40 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index b2dd941..552a018 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -55,7 +55,7 @@ BEGIN { %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] ); $ldap = C4::Context->config('useldapserver') || 0; $cas = C4::Context->preference('casAuthentication'); - $shib = C4::Context->preference('shibbolethAuthentication'); + $shib = C4::Context->config('useshibboleth') || 0; $caslogout = C4::Context->preference('casLogout'); require C4::Auth_with_cas; # no import require C4::Auth_with_Shibboleth; @@ -825,7 +825,7 @@ sub checkauth { || $userid || $shib || $pki_field ne 'None' - || $persona ) + || $persona ) { my $password = $query->param('password'); @@ -1083,7 +1083,7 @@ sub checkauth { login => 1, INPUTS => \@inputs, casAuthentication => C4::Context->preference("casAuthentication"), - shibbolethAuthentication => C4::Context->preference("shibbolethAuthentication"), + shibbolethAuthentication => $shib, suggestion => C4::Context->preference("suggestion"), virtualshelves => C4::Context->preference("virtualshelves"), LibraryName => "" . C4::Context->preference("LibraryName"), @@ -1602,11 +1602,6 @@ sub checkpw { # (defined in the shibbolethLoginAttribute) tto contain the login of the # shibboleth-authenticated user - # Shibboleth attributes are mapped into http environmement variables, - # so we're getting the login of the user this way - my $attributename = C4::Context->preference('shibbolethLoginAttribute'); - my $attributevalue = $ENV{$attributename}; - # Then, we check if it matches a valid koha user if ($shib_login) { my ( $retval, $retcard, $retuserid ) = C4::Auth_with_Shibboleth::checkpw_shib( $dbh, $shib_login ); # EXTERNAL AUTH diff --git a/C4/Auth_with_Shibboleth.pm b/C4/Auth_with_Shibboleth.pm index 13f4b79..5c6c6b3 100644 --- a/C4/Auth_with_Shibboleth.pm +++ b/C4/Auth_with_Shibboleth.pm @@ -22,6 +22,7 @@ use warnings; use C4::Debug; use C4::Context; +use Carp; use CGI; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug); @@ -64,11 +65,13 @@ sub get_login_shib { # Shibboleth attributes are mapped into http environmement variables, # so we're getting the login of the user this way - my $shibbolethLoginAttribute = C4::Context->preference('shibbolethLoginAttribute'); - $debug and warn "shibbolethLoginAttribute value: $shibbolethLoginAttribute"; + my $shib = C4::Context->config('shibboleth') or croak 'No in koha-conf.xml'; + + my $shibbolethLoginAttribute = $shib->{'userid'}; + $debug and warn "shibboleth->userid value: $shibbolethLoginAttribute"; $debug and warn "$shibbolethLoginAttribute value: " . $ENV{$shibbolethLoginAttribute}; - return $ENV{$shibbolethLoginAttribute}; + return $ENV{$shibbolethLoginAttribute} || ''; } # Checks for password correctness @@ -80,6 +83,8 @@ sub checkpw_shib { my $retnumber; $debug and warn "User Shibboleth-authenticated as: $userid"; + my $shib = C4::Context->config('shibboleth') or croak 'No in koha-conf.xml'; + # Does it match one of our users ? my $sth = $dbh->prepare("select cardnumber from borrowers where userid=?"); $sth->execute($userid); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 5cd48f6..6ea5911 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8781,14 +8781,6 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } -$DBversion = "XXX"; -if (C4::Context->preference("Version") < TransformToNum($DBversion)) { - $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('shibbolethAuthentication','','','Enable or disable Shibboleth authentication','YesNo')"); - $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('shibbolethLoginAttribute','','','Which shibboleth user attribute should be used to match koha user login?','')"); - print "Upgrade to $DBversion done (Adds shibbolethAuthentication and shibbolethLoginAttribute preferences)\n"; - SetVersion ($DBversion); -} - =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref index 32665b2..1215ac1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -105,17 +105,6 @@ Administration: yes: Allow no: "Don't Allow" - Mozilla persona for login - Shibboleth Authentication: - - - - pref: shibbolethAuthentication - default: 0 - choices: - yes: Use - no: "Don't use" - - Shibboleth for login authentication. - - - - Which shibboleth user attribute should be used to match koha user login? - - pref: shibbolethLoginAttribute Search Engine: - - pref: SearchEngine diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt index e8f0503..0158bd1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt @@ -57,6 +57,22 @@ [% END %] + [% IF ( shibbolethAuthentication ) %] +

Shibboleth Login

+ + [% IF ( invalidShibLogin ) %] + +

Sorry, the Shibboleth login failed.

+ [% END %] + +

If you have a Shibboleth account, + please click here to login.

+ +

Local Login

+

If you do not have a Shibboleth account, but a local account, you can still log in :

+ + [% END %] + [% IF ( casAuthentication ) %]

CAS login

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt index 5486492..bda8913 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -65,7 +65,7 @@
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %] [% UNLESS ( loggedinusername ) %] - [% UNLESS ( casAuthentication ) %] + [% UNLESS ( casAuthentication || shibbolethAuthentication ) %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt index 9bf09c5..4d561ba 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt @@ -51,14 +51,14 @@ [% IF ( invalidShibLogin ) %] -

Sorry, the shibboleth login failed.

+

Sorry, the Shibboleth login failed.

[% END %] -

If you have a shibboleth account, +

If you have a Shibboleth account, please click here to login.

Local Login

-

If you do not have a shibboleth account, but a local account, you can still log in :

+

If you do not have a Shibboleth account, but a local account, you can still log in :

[% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt index 4a783e5..dd3c3e2 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-main.tt @@ -46,8 +46,7 @@
[% IF ( opacuserlogin ) %] [% UNLESS ( loggedinusername ) %] - [% UNLESS ( casAuthentication ) %] - [% UNLESS ( shibbolethAuthentication ) %] + [% UNLESS ( casAuthentication || shibbolethAuthentication ) %]
diff --git a/opac/opac-main.pl b/opac/opac-main.pl index 6eb6add..b1b92c0 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -44,8 +44,7 @@ $template->param( casAuthentication => $casAuthentication, ); -my $shibbolethAuthentication = C4::Context->preference('shibbolethAuthentication'); -$template->param( shibbolethAuthentication => $shibbolethAuthentication); +$template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') ); # display news # use cookie setting for language, bug default to syspref if it's not set diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 9c7f292..aae78ec 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -74,8 +74,7 @@ for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { my $patronupdate = $query->param('patronupdate'); my $canrenew = 1; -my $shibbolethAuthentication = C4::Context->preference('shibbolethAuthentication'); -$template->param( shibbolethAuthentication => $shibbolethAuthentication ); +$template->param( shibbolethAuthentication => C4::Context->config('useshibboleth') ); # get borrower information .... my ( $borr ) = GetMemberDetails( $borrowernumber ); -- 1.9.1