|
Lines 52-58
BEGIN {
Link Here
|
| 52 |
} |
52 |
} |
| 53 |
if ($cas) { |
53 |
if ($cas) { |
| 54 |
require C4::Auth_with_cas; # no import |
54 |
require C4::Auth_with_cas; # no import |
| 55 |
import C4::Auth_with_cas qw(checkpw_cas login_cas logout_cas login_cas_url); |
55 |
import C4::Auth_with_cas qw(check_api_auth_cas checkpw_cas login_cas logout_cas login_cas_url); |
| 56 |
} |
56 |
} |
| 57 |
|
57 |
|
| 58 |
} |
58 |
} |
|
Lines 121-128
Output.pm module.
Link Here
|
| 121 |
=cut |
121 |
=cut |
| 122 |
|
122 |
|
| 123 |
my $SEARCH_HISTORY_INSERT_SQL =<<EOQ; |
123 |
my $SEARCH_HISTORY_INSERT_SQL =<<EOQ; |
| 124 |
INSERT INTO search_history(userid, sessionid, query_desc, query_cgi, total, time ) |
124 |
INSERT INTO search_history(userid, sessionid, query_desc, query_cgi, limit_desc, limit_cgi, total, time ) |
| 125 |
VALUES ( ?, ?, ?, ?, ?, FROM_UNIXTIME(?)) |
125 |
VALUES ( ?, ?, ?, ?, ?, ?, ?, FROM_UNIXTIME(?)) |
| 126 |
EOQ |
126 |
EOQ |
| 127 |
sub get_template_and_user { |
127 |
sub get_template_and_user { |
| 128 |
my $in = shift; |
128 |
my $in = shift; |
|
Lines 252-264
sub get_template_and_user {
Link Here
|
| 252 |
my @recentSearches = @{thaw($searchcookie) || []}; |
252 |
my @recentSearches = @{thaw($searchcookie) || []}; |
| 253 |
if (@recentSearches) { |
253 |
if (@recentSearches) { |
| 254 |
my $sth = $dbh->prepare($SEARCH_HISTORY_INSERT_SQL); |
254 |
my $sth = $dbh->prepare($SEARCH_HISTORY_INSERT_SQL); |
| 255 |
$sth->execute( $borrowernumber, |
255 |
|
| 256 |
$in->{'query'}->cookie("CGISESSID"), |
256 |
$sth->execute( $borrowernumber, $in->{'query'}->cookie("CGISESSID"), $_->{'query_desc'}, $_->{'query_cgi'}, $_->{'limit_desc'}, $_->{'limit_cgi'}, $_->{'total'}, $_->{'time'}, ) |
| 257 |
$_->{'query_desc'}, |
257 |
foreach @recentSearches; |
| 258 |
$_->{'query_cgi'}, |
|
|
| 259 |
$_->{'total'}, |
| 260 |
$_->{'time'}, |
| 261 |
) foreach @recentSearches; |
| 262 |
|
258 |
|
| 263 |
# And then, delete the cookie's content |
259 |
# And then, delete the cookie's content |
| 264 |
my $newsearchcookie = $in->{'query'}->cookie( |
260 |
my $newsearchcookie = $in->{'query'}->cookie( |
|
Lines 549-563
sub _version_check ($$) {
Link Here
|
| 549 |
# and so we must redirect to OPAC maintenance page or to the WebInstaller |
545 |
# and so we must redirect to OPAC maintenance page or to the WebInstaller |
| 550 |
# also, if OpacMaintenance is ON, OPAC should redirect to maintenance |
546 |
# also, if OpacMaintenance is ON, OPAC should redirect to maintenance |
| 551 |
if (C4::Context->preference('OpacMaintenance') && $type eq 'opac') { |
547 |
if (C4::Context->preference('OpacMaintenance') && $type eq 'opac') { |
| 552 |
warn "OPAC Install required, redirecting to maintenance"; |
|
|
| 553 |
print $query->redirect("/cgi-bin/koha/maintenance.pl"); |
| 554 |
} |
| 555 |
unless ($version = C4::Context->preference('Version')) { # assignment, not comparison |
| 556 |
if ($type ne 'opac') { |
| 557 |
warn "Install required, redirecting to Installer"; |
| 558 |
print $query->redirect("/cgi-bin/koha/installer/install.pl"); |
| 559 |
} |
| 560 |
else { |
| 561 |
warn "OPAC Install required, redirecting to maintenance"; |
548 |
warn "OPAC Install required, redirecting to maintenance"; |
| 562 |
print $query->redirect("/cgi-bin/koha/maintenance.pl"); |
549 |
print $query->redirect("/cgi-bin/koha/maintenance.pl"); |
| 563 |
} |
550 |
} |
|
Lines 616-621
sub checkauth {
Link Here
|
| 616 |
my ( $userid, $cookie, $sessionID, $flags, $barshelves, $pubshelves ); |
603 |
my ( $userid, $cookie, $sessionID, $flags, $barshelves, $pubshelves ); |
| 617 |
my $logout = $query->param('logout.x'); |
604 |
my $logout = $query->param('logout.x'); |
| 618 |
|
605 |
|
|
|
606 |
# This parameter is the name of the CAS server we want to authenticate against, |
| 607 |
# when using authentication against multiple CAS servers, as configured in Auth_cas_servers.yaml |
| 608 |
my $casparam = $query->param('cas'); |
| 609 |
|
| 619 |
if ( $userid = $ENV{'REMOTE_USER'} ) { |
610 |
if ( $userid = $ENV{'REMOTE_USER'} ) { |
| 620 |
# Using Basic Authentication, no cookies required |
611 |
# Using Basic Authentication, no cookies required |
| 621 |
$cookie = $query->cookie( |
612 |
$cookie = $query->cookie( |
|
Lines 954-964
sub checkauth {
Link Here
|
| 954 |
|
945 |
|
| 955 |
if ($cas) { |
946 |
if ($cas) { |
| 956 |
$template->param( |
947 |
$template->param( |
| 957 |
casServerUrl => login_cas_url(), |
948 |
casServerUrl => login_cas_url($query), |
| 958 |
invalidCasLogin => $info{'invalidCasLogin'} |
949 |
invalidCasLogin => $info{'invalidCasLogin'} |
| 959 |
); |
950 |
); |
| 960 |
} |
951 |
} |
| 961 |
|
|
|
| 962 |
my $self_url = $query->url( -absolute => 1 ); |
952 |
my $self_url = $query->url( -absolute => 1 ); |
| 963 |
$template->param( |
953 |
$template->param( |
| 964 |
url => $self_url, |
954 |
url => $self_url, |
|
Lines 1046-1052
sub check_api_auth {
Link Here
|
| 1046 |
unless ($query->param('userid')) { |
1036 |
unless ($query->param('userid')) { |
| 1047 |
$sessionID = $query->cookie("CGISESSID"); |
1037 |
$sessionID = $query->cookie("CGISESSID"); |
| 1048 |
} |
1038 |
} |
| 1049 |
if ($sessionID) { |
1039 |
if ($sessionID && not $cas) { |
| 1050 |
my $session = get_session($sessionID); |
1040 |
my $session = get_session($sessionID); |
| 1051 |
C4::Context->_new_userenv($sessionID); |
1041 |
C4::Context->_new_userenv($sessionID); |
| 1052 |
if ($session) { |
1042 |
if ($session) { |
|
Lines 1096-1113
sub check_api_auth {
Link Here
|
| 1096 |
# new login |
1086 |
# new login |
| 1097 |
my $userid = $query->param('userid'); |
1087 |
my $userid = $query->param('userid'); |
| 1098 |
my $password = $query->param('password'); |
1088 |
my $password = $query->param('password'); |
| 1099 |
unless ($userid and $password) { |
1089 |
my ($return, $cardnumber); |
| 1100 |
# caller did something wrong, fail the authenticateion |
1090 |
|
| 1101 |
return ("failed", undef, undef); |
1091 |
# Proxy CAS auth |
| 1102 |
} |
1092 |
if ($cas && $query->param('PT')) { |
| 1103 |
my ($return, $cardnumber); |
|
|
| 1104 |
if ($cas && $query->param('ticket')) { |
| 1105 |
my $retuserid; |
1093 |
my $retuserid; |
| 1106 |
( $return, $cardnumber, $retuserid ) = checkpw( $dbh, $userid, $password, $query ); |
1094 |
$debug and print STDERR "## check_api_auth - checking CAS\n"; |
| 1107 |
$userid = $retuserid; |
1095 |
# In case of a CAS authentication, we use the ticket instead of the password |
|
|
1096 |
my $PT = $query->param('PT'); |
| 1097 |
($return,$cardnumber,$userid) = check_api_auth_cas($dbh, $PT, $query); # EXTERNAL AUTH |
| 1108 |
} else { |
1098 |
} else { |
|
|
1099 |
# User / password auth |
| 1100 |
unless ($userid and $password) { |
| 1101 |
# caller did something wrong, fail the authenticateion |
| 1102 |
return ("failed", undef, undef); |
| 1103 |
} |
| 1109 |
( $return, $cardnumber ) = checkpw( $dbh, $userid, $password, $query ); |
1104 |
( $return, $cardnumber ) = checkpw( $dbh, $userid, $password, $query ); |
| 1110 |
} |
1105 |
} |
|
|
1106 |
|
| 1111 |
if ($return and haspermission( $userid, $flagsrequired)) { |
1107 |
if ($return and haspermission( $userid, $flagsrequired)) { |
| 1112 |
my $session = get_session(""); |
1108 |
my $session = get_session(""); |
| 1113 |
return ("failed", undef, undef) unless $session; |
1109 |
return ("failed", undef, undef) unless $session; |
|
Lines 1361-1367
sub checkpw {
Link Here
|
| 1361 |
($retval) and return ($retval,$retcard); |
1357 |
($retval) and return ($retval,$retcard); |
| 1362 |
} |
1358 |
} |
| 1363 |
|
1359 |
|
| 1364 |
if ($cas && $query->param('ticket')) { |
1360 |
if ($cas && $query && $query->param('ticket')) { |
| 1365 |
$debug and print STDERR "## checkpw - checking CAS\n"; |
1361 |
$debug and print STDERR "## checkpw - checking CAS\n"; |
| 1366 |
# In case of a CAS authentication, we use the ticket instead of the password |
1362 |
# In case of a CAS authentication, we use the ticket instead of the password |
| 1367 |
my $ticket = $query->param('ticket'); |
1363 |
my $ticket = $query->param('ticket'); |