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; |