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 |
$servers = C4::Context->config('memcached_servers'); |
57 |
$servers = C4::Context->config('memcached_servers'); |
58 |
if ($servers) { |
58 |
if ($servers) { |
Lines 1079-1085
sub check_api_auth {
Link Here
|
1079 |
unless ($query->param('userid')) { |
1079 |
unless ($query->param('userid')) { |
1080 |
$sessionID = $query->cookie("CGISESSID"); |
1080 |
$sessionID = $query->cookie("CGISESSID"); |
1081 |
} |
1081 |
} |
1082 |
if ($sessionID) { |
1082 |
if ($sessionID && not $cas) { |
1083 |
my $session = get_session($sessionID); |
1083 |
my $session = get_session($sessionID); |
1084 |
C4::Context->_new_userenv($sessionID); |
1084 |
C4::Context->_new_userenv($sessionID); |
1085 |
if ($session) { |
1085 |
if ($session) { |
Lines 1129-1146
sub check_api_auth {
Link Here
|
1129 |
# new login |
1129 |
# new login |
1130 |
my $userid = $query->param('userid'); |
1130 |
my $userid = $query->param('userid'); |
1131 |
my $password = $query->param('password'); |
1131 |
my $password = $query->param('password'); |
1132 |
unless ($userid and $password) { |
1132 |
my ($return, $cardnumber); |
1133 |
# caller did something wrong, fail the authenticateion |
1133 |
|
1134 |
return ("failed", undef, undef); |
1134 |
# Proxy CAS auth |
1135 |
} |
1135 |
if ($cas && $query->param('PT')) { |
1136 |
my ($return, $cardnumber); |
|
|
1137 |
if ($cas && $query->param('ticket')) { |
1138 |
my $retuserid; |
1136 |
my $retuserid; |
1139 |
( $return, $cardnumber, $retuserid ) = checkpw( $dbh, $userid, $password, $query ); |
1137 |
$debug and print STDERR "## check_api_auth - checking CAS\n"; |
1140 |
$userid = $retuserid; |
1138 |
# In case of a CAS authentication, we use the ticket instead of the password |
|
|
1139 |
my $PT = $query->param('PT'); |
1140 |
($return,$cardnumber,$userid) = check_api_auth_cas($dbh, $PT, $query); # EXTERNAL AUTH |
1141 |
} else { |
1141 |
} else { |
|
|
1142 |
# User / password auth |
1143 |
unless ($userid and $password) { |
1144 |
# caller did something wrong, fail the authenticateion |
1145 |
return ("failed", undef, undef); |
1146 |
} |
1142 |
( $return, $cardnumber ) = checkpw( $dbh, $userid, $password, $query ); |
1147 |
( $return, $cardnumber ) = checkpw( $dbh, $userid, $password, $query ); |
1143 |
} |
1148 |
} |
|
|
1149 |
|
1144 |
if ($return and haspermission( $userid, $flagsrequired)) { |
1150 |
if ($return and haspermission( $userid, $flagsrequired)) { |
1145 |
my $session = get_session(""); |
1151 |
my $session = get_session(""); |
1146 |
return ("failed", undef, undef) unless $session; |
1152 |
return ("failed", undef, undef) unless $session; |