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

(-)a/C4/Auth.pm (-25 / +23 lines)
Lines 24-29 use Carp qw( croak ); Link Here
24
use Digest::MD5 qw( md5_base64 );
24
use Digest::MD5 qw( md5_base64 );
25
use CGI::Session;
25
use CGI::Session;
26
use CGI::Session::ErrorHandler;
26
use CGI::Session::ErrorHandler;
27
use Data::Session;
27
use URI;
28
use URI;
28
use URI::QueryParam;
29
use URI::QueryParam;
29
30
Lines 1227-1233 sub checkauth { Link Here
1227
                    $session->param( 'desk_name',     $desk_name);
1228
                    $session->param( 'desk_name',     $desk_name);
1228
                    $session->param( 'flags',        $userflags );
1229
                    $session->param( 'flags',        $userflags );
1229
                    $session->param( 'emailaddress', $emailaddress );
1230
                    $session->param( 'emailaddress', $emailaddress );
1230
                    $session->param( 'ip',           $session->remote_addr() );
1231
                    $session->param( 'ip',           $ENV{REMOTE_ADDR} );
1231
                    $session->param( 'lasttime',     time() );
1232
                    $session->param( 'lasttime',     time() );
1232
                    $session->param( 'interface',    $type);
1233
                    $session->param( 'interface',    $type);
1233
                    $session->param( 'shibboleth',   $shibSuccess );
1234
                    $session->param( 'shibboleth',   $shibSuccess );
Lines 1255-1261 sub checkauth { Link Here
1255
                    C4::Context::_unset_userenv($sessionID);
1256
                    C4::Context::_unset_userenv($sessionID);
1256
                }
1257
                }
1257
                $session->param( 'lasttime', time() );
1258
                $session->param( 'lasttime', time() );
1258
                $session->param( 'ip',       $session->remote_addr() );
1259
                $session->param( 'ip', $ENV{REMOTE_ADDR} );
1259
                $session->param( 'sessiontype', 'anon' );
1260
                $session->param( 'sessiontype', 'anon' );
1260
                $session->param( 'interface', $type);
1261
                $session->param( 'interface', $type);
1261
            }
1262
            }
Lines 1265-1271 sub checkauth { Link Here
1265
            # anonymous sessions are created only for the OPAC
1266
            # anonymous sessions are created only for the OPAC
1266
1267
1267
            # setting a couple of other session vars...
1268
            # setting a couple of other session vars...
1268
            $session->param( 'ip',          $session->remote_addr() );
1269
            $session->param( 'ip', $ENV{REMOTE_ADDR} );
1269
            $session->param( 'lasttime',    time() );
1270
            $session->param( 'lasttime',    time() );
1270
            $session->param( 'sessiontype', 'anon' );
1271
            $session->param( 'sessiontype', 'anon' );
1271
            $session->param( 'interface', $type);
1272
            $session->param( 'interface', $type);
Lines 1662-1668 sub check_api_auth { Link Here
1662
                $session->param( 'branchname',   $branchname );
1663
                $session->param( 'branchname',   $branchname );
1663
                $session->param( 'flags',        $userflags );
1664
                $session->param( 'flags',        $userflags );
1664
                $session->param( 'emailaddress', $emailaddress );
1665
                $session->param( 'emailaddress', $emailaddress );
1665
                $session->param( 'ip',           $session->remote_addr() );
1666
                $session->param( 'ip', $ENV{REMOTE_ADDR} );
1666
                $session->param( 'lasttime',     time() );
1667
                $session->param( 'lasttime',     time() );
1667
                $session->param( 'interface',    'api'  );
1668
                $session->param( 'interface',    'api'  );
1668
            }
1669
            }
Lines 1827-1836 sub check_cookie_auth { Link Here
1827
1828
1828
=head2 get_session
1829
=head2 get_session
1829
1830
1830
  use CGI::Session;
1831
  my $session = get_session($sessionID);
1831
  my $session = get_session($sessionID);
1832
1832
1833
Given a session ID, retrieve the CGI::Session object used to store
1833
Given a session ID, retrieve the Data::Session object used to store
1834
the session's state.  The session object can be used to store
1834
the session's state.  The session object can be used to store
1835
data that needs to be accessed by different scripts during a
1835
data that needs to be accessed by different scripts during a
1836
user's session.
1836
user's session.
Lines 1844-1878 sub _get_session_params { Link Here
1844
    my $storage_method = C4::Context->preference('SessionStorage');
1844
    my $storage_method = C4::Context->preference('SessionStorage');
1845
    if ( $storage_method eq 'mysql' ) {
1845
    if ( $storage_method eq 'mysql' ) {
1846
        my $dbh = C4::Context->dbh;
1846
        my $dbh = C4::Context->dbh;
1847
        return { dsn => "serializer:yamlxs;driver:MySQL;id:md5", dsn_args => { Handle => $dbh } };
1847
        # Note that the doc is wrong, type is required, if not provided it default to File
1848
    }
1848
        return { dbh => $dbh, type => 'serialize:yamlxs;driver:mysql;id:MD5' };
1849
    elsif ( $storage_method eq 'Pg' ) {
1849
    } elsif ( $storage_method eq 'Pg' ) {
1850
        my $dbh = C4::Context->dbh;
1850
        die "The system preference SessionStorage is set to 'Pg' but this is not supported yet!";
1851
        return { dsn => "serializer:yamlxs;driver:PostgreSQL;id:md5", dsn_args => { Handle => $dbh } };
1851
    } elsif ( $storage_method eq 'memcached' and my $memcached = Koha::Caches->get_instance->memcached_cache ) {
1852
    }
1852
        return {
1853
    elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) {
1853
            type  => 'serialize:yamlxs;driver:Memcached;id:SHA1',
1854
        my $memcached = Koha::Caches->get_instance()->memcached_cache;
1854
            cache => $memcached,
1855
        return { dsn => "serializer:yamlxs;driver:memcached;id:md5", dsn_args => { Memcached => $memcached } };
1855
        };
1856
    } elsif ( $storage_method ne 'tmp' ) {
1857
        warn "The system preference SessionStorage is set to an invalid value '$storage_method'";
1856
    }
1858
    }
1857
    else {
1859
    else {
1858
        # catch all defaults to tmp should work on all systems
1860
        # catch all defaults to tmp should work on all systems
1861
        if ( $storage_method ne 'tmp' ) {
1862
            warn "The session has not been correctly retrieved, defaulting to temporary storage: " . $Data::Session::errstr;
1863
        }
1859
        my $dir = C4::Context::temporary_directory;
1864
        my $dir = C4::Context::temporary_directory;
1860
        my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is
1865
        my $instance = C4::Context->config('database');    #actually for packages not exactly the instance name, but generally safer to leave it as it is
1861
        return { dsn => "serializer:yamlxs;driver:File;id:md5", dsn_args => { Directory => "$dir/cgisess_$instance" } };
1866
        return { type => 'serialize:yamlxs;driver:File;id:MD5', directory => "$dir/cgisess_$instance" };
1862
    }
1867
    }
1863
}
1868
}
1864
1869
1865
sub get_session {
1870
sub get_session {
1866
    my $sessionID      = shift;
1871
    my $sessionID      = shift;
1867
    my $params = _get_session_params();
1872
    my $params = _get_session_params();
1868
    my $session;
1873
    my $session = Data::Session->new( %$params ) || die $Data::Session::errstr;
1869
    if( $sessionID ) { # find existing
1870
        CGI::Session::ErrorHandler->set_error( q{} ); # clear error, cpan issue #111463
1871
        $session = CGI::Session->load( $params->{dsn}, $sessionID, $params->{dsn_args} );
1872
    } else {
1873
        $session = CGI::Session->new( $params->{dsn}, $sessionID, $params->{dsn_args} );
1874
        # no need to flush here
1875
    }
1876
    return $session;
1874
    return $session;
1877
}
1875
}
1878
1876
(-)a/C4/InstallAuth.pm (-7 / +11 lines)
Lines 18-24 package C4::InstallAuth; Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use CGI::Session;
21
use Data::Session;
22
use File::Spec;
22
use File::Spec;
23
23
24
require Exporter;
24
require Exporter;
Lines 240-250 sub checkauth { Link Here
240
    my %info;
240
    my %info;
241
    my ( $userid, $cookie, $sessionID, $flags, $envcookie );
241
    my ( $userid, $cookie, $sessionID, $flags, $envcookie );
242
    my $logout = $query->param('logout.x');
242
    my $logout = $query->param('logout.x');
243
    my $dir = File::Spec->tmpdir;
243
    if ( $sessionID = $query->cookie("CGISESSID") ) {
244
    if ( $sessionID = $query->cookie("CGISESSID") ) {
244
        C4::Context->_new_userenv($sessionID);
245
        C4::Context->_new_userenv($sessionID);
245
        my $session =
246
        my $session = Data::Session->new(
246
          CGI::Session->new( "driver:File", $sessionID,
247
            type => 'driver:File;id:MD5',
247
            { Directory => $sessdir } );
248
            directory => $dir
249
        ) or die $Data::Session::errstr;
248
        if ( $session->param('cardnumber') ) {
250
        if ( $session->param('cardnumber') ) {
249
            C4::Context->set_userenv(
251
            C4::Context->set_userenv(
250
                $session->param('number'),
252
                $session->param('number'),
Lines 283-290 sub checkauth { Link Here
283
        }
285
        }
284
    }
286
    }
285
    unless ($userid) {
287
    unless ($userid) {
286
        my $session =
288
        my $session = Data::Session->new(
287
          CGI::Session->new( "driver:File", undef, { Directory => $sessdir } );
289
            type => 'driver:File;id:MD5',
290
            directory => $dir
291
        ) or die $Data::Session::errstr;
288
        $sessionID = $session->id;
292
        $sessionID = $session->id;
289
        $userid    = $query->param('userid');
293
        $userid    = $query->param('userid');
290
        C4::Context->_new_userenv($sessionID);
294
        C4::Context->_new_userenv($sessionID);
Lines 327-333 sub checkauth { Link Here
327
                $session->param( 'flags',      1 );
331
                $session->param( 'flags',      1 );
328
                $session->param( 'emailaddress',
332
                $session->param( 'emailaddress',
329
                    C4::Context->preference('KohaAdminEmailAddress') );
333
                    C4::Context->preference('KohaAdminEmailAddress') );
330
                $session->param( 'ip',       $session->remote_addr() );
334
                $session->param( 'ip',         $ENV{REMOTE_ADDR} );
331
                $session->param( 'lasttime', time() );
335
                $session->param( 'lasttime', time() );
332
                $userid = C4::Context->config('user');
336
                $userid = C4::Context->config('user');
333
            }
337
            }
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 40-46 use C4::Search qw( new_record_from_zebra ); Link Here
40
use C4::Reserves;
40
use C4::Reserves;
41
use Koha::Holds;
41
use Koha::Holds;
42
use C4::Context;
42
use C4::Context;
43
use CGI::Session;
43
use Data::Session;
44
use Koha::AuthorisedValues;
44
use Koha::AuthorisedValues;
45
use Koha::CsvProfiles;
45
use Koha::CsvProfiles;
46
use Koha::Patrons;
46
use Koha::Patrons;
(-)a/cpanfile (-1 / +3 lines)
Lines 11-17 requires 'CGI', '3.15'; Link Here
11
requires 'CGI::Carp', '1.29';
11
requires 'CGI::Carp', '1.29';
12
requires 'CGI::Compile', '>= 0.17, != 0.24';
12
requires 'CGI::Compile', '>= 0.17, != 0.24';
13
requires 'CGI::Emulate::PSGI', '0.20';
13
requires 'CGI::Emulate::PSGI', '0.20';
14
requires 'CGI::Session', '4.2';
15
requires 'CPAN::Meta', '2.150006';
14
requires 'CPAN::Meta', '2.150006';
16
requires 'Cache::Memcached', '1.30';
15
requires 'Cache::Memcached', '1.30';
17
requires 'Cache::Memcached::Fast::Safe', '0.06';
16
requires 'Cache::Memcached::Fast::Safe', '0.06';
Lines 28-33 requires 'DBIx::Class::Schema::Loader', '0.07039'; Link Here
28
requires 'DBIx::RunSQL', '0.14';
27
requires 'DBIx::RunSQL', '0.14';
29
requires 'Data::Dumper', '2.121';
28
requires 'Data::Dumper', '2.121';
30
requires 'Data::ICal', '0.13';
29
requires 'Data::ICal', '0.13';
30
requires 'Data::Session', '1.18';
31
requires 'Data::Session::Driver::Memcached', '1.18';
32
requires 'Data::Session::Driver::mysql', '1.18';
31
requires 'Date::Calc', '5.4';
33
requires 'Date::Calc', '5.4';
32
requires 'Date::Manip', '5.44';
34
requires 'Date::Manip', '5.44';
33
requires 'DateTime', '0.58';
35
requires 'DateTime', '0.58';
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (-1 lines)
Lines 113-119 Administration: Link Here
113
              default: mysql
113
              default: mysql
114
              choices:
114
              choices:
115
                  mysql: MySQL database
115
                  mysql: MySQL database
116
                  Pg: PostgreSQL database (not supported)
117
                  tmp: Temporary files
116
                  tmp: Temporary files
118
                  memcached: Memcached server
117
                  memcached: Memcached server
119
        -
118
        -
(-)a/members/routing-lists.pl (-2 lines)
Lines 25-31 use C4::Members; Link Here
25
use C4::Context;
25
use C4::Context;
26
use C4::Serials;
26
use C4::Serials;
27
use Koha::Patrons;
27
use Koha::Patrons;
28
use CGI::Session;
29
28
30
my $query = CGI->new;
29
my $query = CGI->new;
31
30
32
- 

Return to bug 17427