Bug 19160: Move the code from controller to C4::Auth_with_cas
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
e8857894bd
commit
b85f8c9e2a
|
|
@ -86,7 +86,7 @@ BEGIN {
|
|||
}
|
||||
}
|
||||
if ($cas) {
|
||||
import C4::Auth_with_cas qw(check_api_auth_cas checkpw_cas login_cas logout_cas login_cas_url);
|
||||
import C4::Auth_with_cas qw(check_api_auth_cas checkpw_cas login_cas logout_cas login_cas_url logout_required);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,6 +228,23 @@ sub _url_with_get_params {
|
|||
return $uri_base_part . $uri_params_part;
|
||||
}
|
||||
|
||||
sub logout_required {
|
||||
my ( $query ) = @_;
|
||||
# Check we havent been hit by a logout call
|
||||
my $xml = $query->param('logoutRequest');
|
||||
if ($xml) {
|
||||
my $dom = XML::LibXML->load_xml(string => $xml);
|
||||
my $ticket;
|
||||
foreach my $node ($dom->findnodes('/samlp:LogoutRequest')){
|
||||
$ticket = $node->findvalue('./samlp:SessionIndex');
|
||||
}
|
||||
$query->param(-name =>'logout.x', -value => 1);
|
||||
$query->param(-name =>'cas_ticket', -value => $ticket);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
|
|
|||
|
|
@ -61,22 +61,9 @@ BEGIN {
|
|||
import C4::External::BakerTaylor qw(&image_url &link_url);
|
||||
}
|
||||
}
|
||||
my $logout='';
|
||||
# CAS Single Sign Out
|
||||
if (C4::Context->preference('casAuthentication')){
|
||||
# Check we havent been hit by a logout call
|
||||
my $xml = $query->param('logoutRequest');
|
||||
if ($xml) {
|
||||
my $dom = XML::LibXML->load_xml(string => $xml);
|
||||
my $ticket;
|
||||
foreach my $node ($dom->findnodes('/samlp:LogoutRequest')){
|
||||
$ticket = $node->findvalue('./samlp:SessionIndex');
|
||||
}
|
||||
$query->param(-name =>'logout.x', -value => 1);
|
||||
$query->param(-name =>'cas_ticket', -value => $ticket);
|
||||
$logout=1;
|
||||
}
|
||||
}
|
||||
|
||||
my $cas_logout_required = C4::Context->preference('casAuthentication')
|
||||
and C4::Auth_with_ldap::logout_required($query);
|
||||
|
||||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
||||
{
|
||||
|
|
@ -88,7 +75,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
|||
}
|
||||
);
|
||||
|
||||
if ($logout){
|
||||
if ($cas_logout_required){
|
||||
print $query->header;
|
||||
exit;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue