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 1046-1052
sub check_api_auth {
Link Here
|
1046 |
unless ($query->param('userid')) { |
1046 |
unless ($query->param('userid')) { |
1047 |
$sessionID = $query->cookie("CGISESSID"); |
1047 |
$sessionID = $query->cookie("CGISESSID"); |
1048 |
} |
1048 |
} |
1049 |
if ($sessionID) { |
1049 |
if ($sessionID && not $cas) { |
1050 |
my $session = get_session($sessionID); |
1050 |
my $session = get_session($sessionID); |
1051 |
C4::Context->_new_userenv($sessionID); |
1051 |
C4::Context->_new_userenv($sessionID); |
1052 |
if ($session) { |
1052 |
if ($session) { |
Lines 1096-1113
sub check_api_auth {
Link Here
|
1096 |
# new login |
1096 |
# new login |
1097 |
my $userid = $query->param('userid'); |
1097 |
my $userid = $query->param('userid'); |
1098 |
my $password = $query->param('password'); |
1098 |
my $password = $query->param('password'); |
1099 |
unless ($userid and $password) { |
1099 |
my ($return, $cardnumber); |
1100 |
# caller did something wrong, fail the authenticateion |
1100 |
|
1101 |
return ("failed", undef, undef); |
1101 |
# Proxy CAS auth |
1102 |
} |
1102 |
if ($cas && $query->param('PT')) { |
1103 |
my ($return, $cardnumber); |
|
|
1104 |
if ($cas && $query->param('ticket')) { |
1105 |
my $retuserid; |
1103 |
my $retuserid; |
1106 |
( $return, $cardnumber, $retuserid ) = checkpw( $dbh, $userid, $password, $query ); |
1104 |
$debug and print STDERR "## check_api_auth - checking CAS\n"; |
1107 |
$userid = $retuserid; |
1105 |
# In case of a CAS authentication, we use the ticket instead of the password |
|
|
1106 |
my $PT = $query->param('PT'); |
1107 |
($return,$cardnumber,$userid) = check_api_auth_cas($dbh, $PT, $query); # EXTERNAL AUTH |
1108 |
} else { |
1108 |
} else { |
|
|
1109 |
# User / password auth |
1110 |
unless ($userid and $password) { |
1111 |
# caller did something wrong, fail the authenticateion |
1112 |
return ("failed", undef, undef); |
1113 |
} |
1109 |
( $return, $cardnumber ) = checkpw( $dbh, $userid, $password, $query ); |
1114 |
( $return, $cardnumber ) = checkpw( $dbh, $userid, $password, $query ); |
1110 |
} |
1115 |
} |
|
|
1116 |
|
1111 |
if ($return and haspermission( $userid, $flagsrequired)) { |
1117 |
if ($return and haspermission( $userid, $flagsrequired)) { |
1112 |
my $session = get_session(""); |
1118 |
my $session = get_session(""); |
1113 |
return ("failed", undef, undef) unless $session; |
1119 |
return ("failed", undef, undef) unless $session; |