Lines 907-937
sub checkauth {
Link Here
|
907 |
# We got a cas single logout request from a cas server; |
907 |
# We got a cas single logout request from a cas server; |
908 |
my $ticket = $query->param('cas_ticket'); |
908 |
my $ticket = $query->param('cas_ticket'); |
909 |
# We've been called as part of the single logout destroy the session associated with the cas ticket |
909 |
# We've been called as part of the single logout destroy the session associated with the cas ticket |
910 |
my $storage_method = C4::Context->preference('SessionStorage'); |
910 |
my $params = _get_session_params(); |
911 |
my $dsn; |
911 |
my $success = CGI::Session->find( $params->{dsn}, sub {delete_cas_session(@_, $ticket)}, $params->{dsn_args} ); |
912 |
my $dsn_options; |
912 |
|
913 |
# shift this to a function make get_session use the function too |
|
|
914 |
my $dbh = C4::Context->dbh; |
915 |
if ( $storage_method eq 'mysql' ) { |
916 |
$dsn = "driver:MySQL;serializer:yaml;id:md5"; |
917 |
$dsn_options = { Handle => $dbh }; |
918 |
} |
919 |
elsif ( $storage_method eq 'Pg' ) { |
920 |
$dsn = "driver:PostgreSQL;serializer:yaml;id:md5"; |
921 |
$dsn_options = { Handle => $dbh }; |
922 |
} |
923 |
elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) { |
924 |
$dsn = "driver:memcached;serializer:yaml;id:md5"; |
925 |
my $memcached = Koha::Caches->get_instance()->memcached_cache; |
926 |
$dsn_options = { Memcached => $memcached }; |
927 |
} |
928 |
else { |
929 |
$dsn = "driver:File;serializer:yaml;id:md5"; |
930 |
my $dir = File::Spec->tmpdir; |
931 |
my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is |
932 |
$dsn_options = { Directory => "$dir/cgisess_$instance" }; |
933 |
} |
934 |
my $success = CGI::Session->find( $dsn, sub {delete_cas_session(@_, $ticket)}, $dsn_options ); |
935 |
sub delete_cas_session { |
913 |
sub delete_cas_session { |
936 |
my $session = shift; |
914 |
my $session = shift; |
937 |
my $ticket = shift; |
915 |
my $ticket = shift; |
Lines 1767-1794
will be created.
Link Here
|
1767 |
|
1745 |
|
1768 |
=cut |
1746 |
=cut |
1769 |
|
1747 |
|
1770 |
sub get_session { |
1748 |
sub _get_session_params { |
1771 |
my $sessionID = shift; |
|
|
1772 |
my $storage_method = C4::Context->preference('SessionStorage'); |
1749 |
my $storage_method = C4::Context->preference('SessionStorage'); |
1773 |
my $dbh = C4::Context->dbh; |
|
|
1774 |
my $session; |
1775 |
if ( $storage_method eq 'mysql' ) { |
1750 |
if ( $storage_method eq 'mysql' ) { |
1776 |
$session = new CGI::Session( "driver:MySQL;serializer:yaml;id:md5", $sessionID, { Handle => $dbh } ); |
1751 |
my $dbh = C4::Context->dbh; |
|
|
1752 |
return { dsn => "driver:MySQL;serializer:yaml;id:md5", dsn_args => { Handle => $dbh } }; |
1777 |
} |
1753 |
} |
1778 |
elsif ( $storage_method eq 'Pg' ) { |
1754 |
elsif ( $storage_method eq 'Pg' ) { |
1779 |
$session = new CGI::Session( "driver:PostgreSQL;serializer:yaml;id:md5", $sessionID, { Handle => $dbh } ); |
1755 |
my $dbh = C4::Context->dbh; |
|
|
1756 |
return { dsn => "driver:PostgreSQL;serializer:yaml;id:md5", dsn_args => { Handle => $dbh } }; |
1780 |
} |
1757 |
} |
1781 |
elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) { |
1758 |
elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) { |
1782 |
my $memcached = Koha::Caches->get_instance()->memcached_cache; |
1759 |
my $memcached = Koha::Caches->get_instance()->memcached_cache; |
1783 |
$session = new CGI::Session( "driver:memcached;serializer:yaml;id:md5", $sessionID, { Memcached => $memcached } ); |
1760 |
return { dsn => "driver:memcached;serializer:yaml;id:md5", dsn_args => { Memcached => $memcached } }; |
1784 |
} |
1761 |
} |
1785 |
else { |
1762 |
else { |
1786 |
# catch all defaults to tmp should work on all systems |
1763 |
# catch all defaults to tmp should work on all systems |
1787 |
my $dir = File::Spec->tmpdir; |
1764 |
my $dir = File::Spec->tmpdir; |
1788 |
my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is |
1765 |
my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is |
1789 |
$session = new CGI::Session( "driver:File;serializer:yaml;id:md5", $sessionID, { Directory => "$dir/cgisess_$instance" } ); |
1766 |
return { dsn => "driver:File;serializer:yaml;id:md5", dsn_args => { Directory => "$dir/cgisess_$instance" } }; |
1790 |
} |
1767 |
} |
1791 |
return $session; |
1768 |
} |
|
|
1769 |
|
1770 |
sub get_session { |
1771 |
my $sessionID = shift; |
1772 |
my $params = _get_session_params(); |
1773 |
return new CGI::Session( $params->{dsn}, $sessionID, $params->{dsn_args} ); |
1792 |
} |
1774 |
} |
1793 |
|
1775 |
|
1794 |
|
1776 |
|
1795 |
- |
|
|