|
Lines 48-53
use Encode qw( encode is_utf8);
Link Here
|
| 48 |
use C4::Auth_with_shibboleth; |
48 |
use C4::Auth_with_shibboleth; |
| 49 |
use Net::CIDR; |
49 |
use Net::CIDR; |
| 50 |
use C4::Log qw/logaction/; |
50 |
use C4::Log qw/logaction/; |
|
|
51 |
use Koha::AuthN::Plugin; |
| 51 |
|
52 |
|
| 52 |
# use utf8; |
53 |
# use utf8; |
| 53 |
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout); |
54 |
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout); |
|
Lines 817-822
sub checkauth {
Link Here
|
| 817 |
my $type = shift; |
818 |
my $type = shift; |
| 818 |
my $emailaddress = shift; |
819 |
my $emailaddress = shift; |
| 819 |
my $template_name = shift; |
820 |
my $template_name = shift; |
|
|
821 |
|
| 822 |
my $extensions = shift // {}; |
| 823 |
|
| 824 |
my $auth_plugin = $extensions->{auth_plugin}; |
| 825 |
|
| 820 |
$type = 'opac' unless $type; |
826 |
$type = 'opac' unless $type; |
| 821 |
|
827 |
|
| 822 |
unless ( C4::Context->preference("OpacPublic") ) { |
828 |
unless ( C4::Context->preference("OpacPublic") ) { |
|
Lines 904-909
sub checkauth {
Link Here
|
| 904 |
if ( ( $query->param('koha_login_context') && ( $q_userid ne $s_userid ) ) |
910 |
if ( ( $query->param('koha_login_context') && ( $q_userid ne $s_userid ) ) |
| 905 |
|| ( $cas && $query->param('ticket') && !C4::Context->userenv->{'id'} ) |
911 |
|| ( $cas && $query->param('ticket') && !C4::Context->userenv->{'id'} ) |
| 906 |
|| ( $shib && $shib_login && !$logout && !C4::Context->userenv->{'id'} ) |
912 |
|| ( $shib && $shib_login && !$logout && !C4::Context->userenv->{'id'} ) |
|
|
913 |
|| ( $auth_plugin && ! $logout ) |
| 907 |
) { |
914 |
) { |
| 908 |
|
915 |
|
| 909 |
#if a user enters an id ne to the id in the current session, we need to log them in... |
916 |
#if a user enters an id ne to the id in the current session, we need to log them in... |
|
Lines 917-922
sub checkauth {
Link Here
|
| 917 |
$userid = undef; |
924 |
$userid = undef; |
| 918 |
} |
925 |
} |
| 919 |
elsif ($logout) { |
926 |
elsif ($logout) { |
|
|
927 |
#NOTE: Get authentication plugin if we logged in using one |
| 928 |
$auth_plugin = Koha::AuthN::Plugin->get_from_session({ |
| 929 |
session => $session, |
| 930 |
}); |
| 920 |
|
931 |
|
| 921 |
# voluntary logout the user |
932 |
# voluntary logout the user |
| 922 |
# check wether the user was using their shibboleth session or a local one |
933 |
# check wether the user was using their shibboleth session or a local one |
|
Lines 929-934
sub checkauth {
Link Here
|
| 929 |
$sessionID = undef; |
940 |
$sessionID = undef; |
| 930 |
$userid = undef; |
941 |
$userid = undef; |
| 931 |
|
942 |
|
|
|
943 |
#NOTE: Logout using authentication plugin |
| 944 |
if ( $auth_plugin && $auth_plugin->can('do_logout') ){ |
| 945 |
$auth_plugin->do_logout({ |
| 946 |
controller => $query, |
| 947 |
type => $type, |
| 948 |
}); |
| 949 |
} |
| 950 |
|
| 932 |
if ($cas and $caslogout) { |
951 |
if ($cas and $caslogout) { |
| 933 |
logout_cas($query, $type); |
952 |
logout_cas($query, $type); |
| 934 |
} |
953 |
} |
|
Lines 1010-1015
sub checkauth {
Link Here
|
| 1010 |
} |
1029 |
} |
| 1011 |
if ( ( $cas && $query->param('ticket') ) |
1030 |
if ( ( $cas && $query->param('ticket') ) |
| 1012 |
|| $q_userid |
1031 |
|| $q_userid |
|
|
1032 |
|| $auth_plugin |
| 1013 |
|| ( $shib && $shib_login ) |
1033 |
|| ( $shib && $shib_login ) |
| 1014 |
|| $pki_field ne 'None' |
1034 |
|| $pki_field ne 'None' |
| 1015 |
|| $emailaddress ) |
1035 |
|| $emailaddress ) |
|
Lines 1038-1044
sub checkauth {
Link Here
|
| 1038 |
$userid = $retuserid; |
1058 |
$userid = $retuserid; |
| 1039 |
$info{'invalidCasLogin'} = 1 unless ($return); |
1059 |
$info{'invalidCasLogin'} = 1 unless ($return); |
| 1040 |
} |
1060 |
} |
| 1041 |
|
1061 |
elsif ( $auth_plugin ){ |
|
|
1062 |
($return,$userid) = $auth_plugin->do_login({ |
| 1063 |
controller => $query, |
| 1064 |
cookie => $cookie, |
| 1065 |
session => $session, |
| 1066 |
info => \%info, |
| 1067 |
}); |
| 1068 |
} |
| 1042 |
elsif ( $emailaddress ) { |
1069 |
elsif ( $emailaddress ) { |
| 1043 |
my $value = $emailaddress; |
1070 |
my $value = $emailaddress; |
| 1044 |
|
1071 |
|
|
Lines 1221-1226
sub checkauth {
Link Here
|
| 1221 |
$branchname = $branches->{$br}->{'branchname'}; |
1248 |
$branchname = $branches->{$br}->{'branchname'}; |
| 1222 |
} |
1249 |
} |
| 1223 |
} |
1250 |
} |
|
|
1251 |
if ($auth_plugin){ |
| 1252 |
Koha::AuthN::Plugin->set_login_session({ |
| 1253 |
auth_plugin => $auth_plugin, |
| 1254 |
session => $session, |
| 1255 |
}); |
| 1256 |
} |
| 1224 |
$session->param( 'number', $borrowernumber ); |
1257 |
$session->param( 'number', $borrowernumber ); |
| 1225 |
$session->param( 'id', $userid ); |
1258 |
$session->param( 'id', $userid ); |
| 1226 |
$session->param( 'cardnumber', $cardnumber ); |
1259 |
$session->param( 'cardnumber', $cardnumber ); |