View | Details | Raw Unified | Return to bug 19160
Collapse All | Expand All

(-)a/C4/Auth.pm (-16 lines)
Lines 905-926 sub checkauth { Link Here
905
            }
905
            }
906
        }
906
        }
907
    }
907
    }
908
    elsif ($logout && $cas) {
909
        # We got a cas single logout request from a cas server;
910
        my $ticket = $query->param('cas_ticket');
911
        # We've been called as part of the single logout destroy the session associated with the cas ticket
912
        my $params = _get_session_params();
913
        my $success =  CGI::Session->find( $params->{dsn}, sub {delete_cas_session(@_, $ticket)}, $params->{dsn_args} );
914
915
        sub delete_cas_session {
916
            my $session = shift;
917
            my $ticket = shift;
918
            if ($session->param('cas_ticket') && $session->param('cas_ticket') eq $ticket ) {
919
                $session->delete;
920
                $session->flush;
921
            }
922
        }
923
    }
924
    unless ( $userid || $sessionID ) {
908
    unless ( $userid || $sessionID ) {
925
        #we initiate a session prior to checking for a username to allow for anonymous sessions...
909
        #we initiate a session prior to checking for a username to allow for anonymous sessions...
926
        my $session = get_session("") or die "Auth ERROR: Cannot get_session()";
910
        my $session = get_session("") or die "Auth ERROR: Cannot get_session()";
(-)a/C4/Auth_with_cas.pm (-10 / +26 lines)
Lines 228-248 sub _url_with_get_params { Link Here
228
    return $uri_base_part . $uri_params_part;
228
    return $uri_base_part . $uri_params_part;
229
}
229
}
230
230
231
sub logout_required {
231
# CAS single logout
232
sub logout_if_required {
232
    my ( $query ) = @_;
233
    my ( $query ) = @_;
233
    # Check we havent been hit by a logout call
234
    # Check we havent been hit by a logout call
234
    my $xml = $query->param('logoutRequest');
235
    my $xml = $query->param('logoutRequest');
235
    if ($xml) {
236
    return 0 unless $xml;
236
        my $dom = XML::LibXML->load_xml(string => $xml);
237
237
        my $ticket;
238
    my $dom = XML::LibXML->load_xml(string => $xml);
238
        foreach my $node ($dom->findnodes('/samlp:LogoutRequest')){
239
    my $ticket;
239
            $ticket = $node->findvalue('./samlp:SessionIndex');
240
    foreach my $node ($dom->findnodes('/samlp:LogoutRequest')){
241
        # We got a cas single logout request from a cas server;
242
        $ticket = $node->findvalue('./samlp:SessionIndex');
243
    }
244
245
    return 0 unless $ticket;
246
247
    # We've been called as part of the single logout destroy the session associated with the cas ticket
248
    my $params = C4::Auth::_get_session_params();
249
    my $success = CGI::Session->find( $params->{dsn}, sub {delete_cas_session(@_, $ticket)}, $params->{dsn_args} );
250
251
    sub delete_cas_session {
252
        my $session = shift;
253
        my $ticket = shift;
254
        if ($session->param('cas_ticket') && $session->param('cas_ticket') eq $ticket ) {
255
            $session->delete;
256
            $session->flush;
240
        }
257
        }
241
        $query->param(-name =>'logout.x', -value => 1);
242
        $query->param(-name =>'cas_ticket', -value => $ticket);
243
        return 1;
244
    }
258
    }
245
    return 0;
259
260
    print $query->header;
261
    exit;
246
}
262
}
247
263
248
1;
264
1;
(-)a/opac/opac-user.pl (-9 / +3 lines)
Lines 61-68 BEGIN { Link Here
61
    }
61
    }
62
}
62
}
63
63
64
my $cas_logout_required = C4::Context->preference('casAuthentication')
64
# CAS single logout handling
65
  and C4::Auth_with_ldap::logout_required($query);
65
# Will print header and exit
66
C4::Context->preference('casAuthentication') and C4::Auth_with_ldap::logout_if_required($query);
66
67
67
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
68
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
68
    {
69
    {
Lines 74-85 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
74
    }
75
    }
75
);
76
);
76
77
77
if ($cas_logout_required){
78
    print $query->header;
79
    exit;
80
}
81
82
83
my %renewed = map { $_ => 1 } split( ':', $query->param('renewed') );
78
my %renewed = map { $_ => 1 } split( ':', $query->param('renewed') );
84
79
85
my $show_priority;
80
my $show_priority;
86
- 

Return to bug 19160