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

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

Return to bug 19160