From 7f14db78dbf8763f4f70149a711da80a79d7ef00 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Mon, 21 Oct 2013 10:17:08 -0600 Subject: [PATCH] [SIGNED OFF] BUG8446, Follow up: Remove unnecessary sysprefs, move to config Signed-off-by: Martin Renvoize --- C4/Auth.pm | 11 +++-------- C4/Auth_with_Shibboleth.pm | 11 ++++++++--- .../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 +-- 9 files changed, 34 insertions(+), 32 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 1674d18..c296ff1 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; @@ -822,7 +822,7 @@ sub checkauth { || $userid || $shib || $pki_field ne 'None' - || $persona ) + || $persona ) { my $password = $query->param('password'); @@ -1080,7 +1080,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"), @@ -1599,11 +1599,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/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 f2196dd..5ee13f0 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 5b68c19..eee397b 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 5793ee4..bf2ce93 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 8852d5f..8c1ef39 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -72,8 +72,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.7.10.4