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

(-)a/C4/Auth.pm (-22 / +26 lines)
Lines 23-29 use Digest::MD5 qw(md5_base64); Link Here
23
use File::Spec;
23
use File::Spec;
24
use JSON qw/encode_json/;
24
use JSON qw/encode_json/;
25
use URI::Escape;
25
use URI::Escape;
26
use CGI::Session;
26
use Data::Session;
27
27
28
require Exporter;
28
require Exporter;
29
use C4::Context;
29
use C4::Context;
Lines 1111-1117 sub checkauth { Link Here
1111
                    $session->param( 'branchname',   $branchname );
1111
                    $session->param( 'branchname',   $branchname );
1112
                    $session->param( 'flags',        $userflags );
1112
                    $session->param( 'flags',        $userflags );
1113
                    $session->param( 'emailaddress', $emailaddress );
1113
                    $session->param( 'emailaddress', $emailaddress );
1114
                    $session->param( 'ip',           $session->remote_addr() );
1114
                    $session->param( 'ip',           $ENV{REMOTE_ADDR} );
1115
                    $session->param( 'lasttime',     time() );
1115
                    $session->param( 'lasttime',     time() );
1116
                    $session->param( 'shibboleth',   $shibSuccess );
1116
                    $session->param( 'shibboleth',   $shibSuccess );
1117
                    $debug and printf STDERR "AUTH_4: (%s)\t%s %s - %s\n", map { $session->param($_) } qw(cardnumber firstname surname branch);
1117
                    $debug and printf STDERR "AUTH_4: (%s)\t%s %s - %s\n", map { $session->param($_) } qw(cardnumber firstname surname branch);
Lines 1129-1135 sub checkauth { Link Here
1129
                    $session->param( 'branchname',   'NO_LIBRARY_SET' );
1129
                    $session->param( 'branchname',   'NO_LIBRARY_SET' );
1130
                    $session->param( 'flags',        1 );
1130
                    $session->param( 'flags',        1 );
1131
                    $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1131
                    $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1132
                    $session->param( 'ip',           $session->remote_addr() );
1132
                    $session->param( 'ip',           $ENV{REMOTE_ADDR} );
1133
                    $session->param( 'lasttime',     time() );
1133
                    $session->param( 'lasttime',     time() );
1134
                }
1134
                }
1135
                if ($persona) {
1135
                if ($persona) {
Lines 1154-1160 sub checkauth { Link Here
1154
                    C4::Context->_unset_userenv($sessionID);
1154
                    C4::Context->_unset_userenv($sessionID);
1155
                }
1155
                }
1156
                $session->param( 'lasttime', time() );
1156
                $session->param( 'lasttime', time() );
1157
                $session->param( 'ip',       $session->remote_addr() );
1157
                $session->param( 'ip', $ENV{REMOTE_ADDR} );
1158
                $session->param( 'sessiontype', 'anon' );
1158
                $session->param( 'sessiontype', 'anon' );
1159
            }
1159
            }
1160
        }    # END if ( $userid    = $query->param('userid') )
1160
        }    # END if ( $userid    = $query->param('userid') )
Lines 1165-1171 sub checkauth { Link Here
1165
            $debug and warn "Initiating an anonymous session...";
1165
            $debug and warn "Initiating an anonymous session...";
1166
1166
1167
            # setting a couple of other session vars...
1167
            # setting a couple of other session vars...
1168
            $session->param( 'ip',          $session->remote_addr() );
1168
            $session->param( 'ip', $ENV{REMOTE_ADDR} );
1169
            $session->param( 'lasttime',    time() );
1169
            $session->param( 'lasttime',    time() );
1170
            $session->param( 'sessiontype', 'anon' );
1170
            $session->param( 'sessiontype', 'anon' );
1171
        }
1171
        }
Lines 1559-1565 sub check_api_auth { Link Here
1559
                $session->param( 'branchname',   $branchname );
1559
                $session->param( 'branchname',   $branchname );
1560
                $session->param( 'flags',        $userflags );
1560
                $session->param( 'flags',        $userflags );
1561
                $session->param( 'emailaddress', $emailaddress );
1561
                $session->param( 'emailaddress', $emailaddress );
1562
                $session->param( 'ip',           $session->remote_addr() );
1562
                $session->param( 'ip', $ENV{REMOTE_ADDR} );
1563
                $session->param( 'lasttime',     time() );
1563
                $session->param( 'lasttime',     time() );
1564
            } elsif ( $return == 2 ) {
1564
            } elsif ( $return == 2 ) {
1565
1565
Lines 1573-1579 sub check_api_auth { Link Here
1573
                $session->param( 'branchname',   'NO_LIBRARY_SET' );
1573
                $session->param( 'branchname',   'NO_LIBRARY_SET' );
1574
                $session->param( 'flags',        1 );
1574
                $session->param( 'flags',        1 );
1575
                $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1575
                $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1576
                $session->param( 'ip',           $session->remote_addr() );
1576
                $session->param( 'ip', $ENV{REMOTE_ADDR} );
1577
                $session->param( 'lasttime',     time() );
1577
                $session->param( 'lasttime',     time() );
1578
            }
1578
            }
1579
            C4::Context->set_userenv(
1579
            C4::Context->set_userenv(
Lines 1709-1718 sub check_cookie_auth { Link Here
1709
1709
1710
=head2 get_session
1710
=head2 get_session
1711
1711
1712
  use CGI::Session;
1713
  my $session = get_session($sessionID);
1712
  my $session = get_session($sessionID);
1714
1713
1715
Given a session ID, retrieve the CGI::Session object used to store
1714
Given a session ID, retrieve the Data::Session object used to store
1716
the session's state.  The session object can be used to store
1715
the session's state.  The session object can be used to store
1717
data that needs to be accessed by different scripts during a
1716
data that needs to be accessed by different scripts during a
1718
user's session.
1717
user's session.
Lines 1728-1747 sub get_session { Link Here
1728
    my $dbh            = C4::Context->dbh;
1727
    my $dbh            = C4::Context->dbh;
1729
    my $session;
1728
    my $session;
1730
    if ( $storage_method eq 'mysql' ) {
1729
    if ( $storage_method eq 'mysql' ) {
1731
        $session = new CGI::Session( "driver:MySQL;serializer:yaml;id:md5", $sessionID, { Handle => $dbh } );
1730
        # Note that the doc is wrong, type is required, if not provided it default to File
1732
    }
1731
        $session = Data::Session->new( dbh => $dbh, type => 'driver:mysql;id:MD5;serialize:YAML' ) or die $Data::Session::errstr;
1733
    elsif ( $storage_method eq 'Pg' ) {
1732
    } elsif ( $storage_method eq 'Pg' ) {
1734
        $session = new CGI::Session( "driver:PostgreSQL;serializer:yaml;id:md5", $sessionID, { Handle => $dbh } );
1733
        warn "The system preference SessionStorage is set to 'Pg' but this is not supported yet!";
1735
    }
1734
    } elsif ( $storage_method eq 'memcached' and my $memcached = Koha::Caches->get_instance->memcached_cache ) {
1736
    elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) {
1735
        $session = Data::Session->new(
1737
        my $memcached = Koha::Caches->get_instance()->memcached_cache;
1736
            type  => 'driver:Memcached;id:SHA1;serialize:DataDumper',
1738
        $session = new CGI::Session( "driver:memcached;serializer:yaml;id:md5", $sessionID, { Memcached => $memcached } );
1737
            cache => $memcached,
1738
        );
1739
    } elsif ( $storage_method ne 'tmp' ) {
1740
        warn "The system preference SessionStorage is set to an invalid value '$storage_method'";
1739
    }
1741
    }
1740
    else {
1742
    if ( $storage_method eq 'tmp' or not $session ) {
1741
        # catch all defaults to tmp should work on all systems
1743
        if ( $storage_method ne 'tmp' ) {
1742
        my $dir = File::Spec->tmpdir;
1744
            warn "The session has not been correctly retrieved, defaulting to temporary storage: " . $Data::Session::errstr;
1743
        my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is
1745
        }
1744
        $session = new CGI::Session( "driver:File;serializer:yaml;id:md5", $sessionID, { Directory => "$dir/cgisess_$instance" } );
1746
        my $dir      = '/tmp/';                            #File::Spec->tmpdir;
1747
        my $instance = C4::Context->config('database');    #actually for packages not exactly the instance name, but generally safer to leave it as it is
1748
        $session = Data::Session->new( type => 'driver:File;id:MD5;serialize:YAML', directory => "$dir/cgisess_$instance" ) or die $Data::Session::errstr;
1745
    }
1749
    }
1746
    return $session;
1750
    return $session;
1747
}
1751
}
(-)a/C4/Context.pm (-3 / +1 lines)
Lines 858-866 set_userenv is called in Auth.pm Link Here
858
#'
858
#'
859
sub set_userenv {
859
sub set_userenv {
860
    shift @_;
860
    shift @_;
861
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona, $shibboleth)=
861
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona, $shibboleth) = @_;
862
    map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here
863
    @_;
864
    my $var=$context->{"activeuser"} || '';
862
    my $var=$context->{"activeuser"} || '';
865
    my $cell = {
863
    my $cell = {
866
        "number"     => $usernum,
864
        "number"     => $usernum,
(-)a/C4/InstallAuth.pm (-7 / +12 lines)
Lines 20-32 package C4::InstallAuth; Link Here
20
use strict;
20
use strict;
21
#use warnings; FIXME - Bug 2505
21
#use warnings; FIXME - Bug 2505
22
use Digest::MD5 qw(md5_base64);
22
use Digest::MD5 qw(md5_base64);
23
use Data::Session;
24
use File::Spec;
23
25
24
require Exporter;
26
require Exporter;
25
use C4::Context;
27
use C4::Context;
26
use C4::Output;
28
use C4::Output;
27
use C4::Templates;
29
use C4::Templates;
28
use C4::Koha;
30
use C4::Koha;
29
use CGI::Session;
30
31
31
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
32
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
32
33
Lines 239-249 sub checkauth { Link Here
239
    my %info;
240
    my %info;
240
    my ( $userid, $cookie, $sessionID, $flags, $envcookie );
241
    my ( $userid, $cookie, $sessionID, $flags, $envcookie );
241
    my $logout = $query->param('logout.x');
242
    my $logout = $query->param('logout.x');
243
    my $dir = File::Spec->tmpdir;
242
    if ( $sessionID = $query->cookie("CGISESSID") ) {
244
    if ( $sessionID = $query->cookie("CGISESSID") ) {
243
        C4::Context->_new_userenv($sessionID);
245
        C4::Context->_new_userenv($sessionID);
244
        my $session =
246
        my $session = Data::Session->new(
245
          new CGI::Session( "driver:File;serializer:yaml", $sessionID,
247
            type => 'driver:File;id:MD5;serialize:YAML',
246
            { Directory => '/tmp' } );
248
            directory => $dir
249
        ) or die $Data::Session::errstr;
247
        if ( $session->param('cardnumber') ) {
250
        if ( $session->param('cardnumber') ) {
248
            C4::Context->set_userenv(
251
            C4::Context->set_userenv(
249
                $session->param('number'),
252
                $session->param('number'),
Lines 282-289 sub checkauth { Link Here
282
        }
285
        }
283
    }
286
    }
284
    unless ($userid) {
287
    unless ($userid) {
285
        my $session =
288
        my $session = Data::Session->new(
286
          new CGI::Session( "driver:File;serializer:yaml", undef, { Directory => '/tmp' } );
289
            type => 'driver:File;id:MD5;serialize:YAML',
290
            directory => $dir
291
        ) or die $Data::Session::errstr;
287
        $sessionID = $session->id;
292
        $sessionID = $session->id;
288
        $userid    = $query->param('userid');
293
        $userid    = $query->param('userid');
289
        C4::Context->_new_userenv($sessionID);
294
        C4::Context->_new_userenv($sessionID);
Lines 324-330 sub checkauth { Link Here
324
                $session->param( 'flags',      1 );
329
                $session->param( 'flags',      1 );
325
                $session->param( 'emailaddress',
330
                $session->param( 'emailaddress',
326
                    C4::Context->preference('KohaAdminEmailAddress') );
331
                    C4::Context->preference('KohaAdminEmailAddress') );
327
                $session->param( 'ip',       $session->remote_addr() );
332
                $session->param( 'ip',         $ENV{REMOTE_ADDR} );
328
                $session->param( 'lasttime', time() );
333
                $session->param( 'lasttime', time() );
329
                $userid = C4::Context->config('user');
334
                $userid = C4::Context->config('user');
330
            }
335
            }
(-)a/C4/Installer/PerlDependencies.pm (-15 / +15 lines)
Lines 317-327 our $PERL_DEPS = { Link Here
317
        'required' => '1',
317
        'required' => '1',
318
        'min_ver'  => '5.43'
318
        'min_ver'  => '5.43'
319
    },
319
    },
320
    'CGI::Session::Serialize::yaml' => {
321
        'usage'    => 'Core',
322
        'required' => '1',
323
        'min_ver'  => '4.2'
324
    },
325
    'CGI::Carp' => {
320
    'CGI::Carp' => {
326
        'usage'    => 'Core',
321
        'usage'    => 'Core',
327
        'required' => '1',
322
        'required' => '1',
Lines 427-442 our $PERL_DEPS = { Link Here
427
        'required' => '1',
422
        'required' => '1',
428
        'min_ver'  => '2'
423
        'min_ver'  => '2'
429
    },
424
    },
430
    'CGI::Session' => {
431
        'usage'    => 'Core',
432
        'required' => '1',
433
        'min_ver'  => '4.2'
434
    },
435
    'CGI::Session::Driver::memcached' => {
436
        'usage'    => 'Memcached Feature (Experimental)',
437
        'required' => '0',
438
        'min_ver'  => '0.04',
439
    },
440
    'POSIX' => {
425
    'POSIX' => {
441
        'usage'    => 'Core',
426
        'usage'    => 'Core',
442
        'required' => '1',
427
        'required' => '1',
Lines 847-852 our $PERL_DEPS = { Link Here
847
        required => 1,
832
        required => 1,
848
        min_ver => '0.058',
833
        min_ver => '0.058',
849
    },
834
    },
835
    'Data::Session' => {
836
        usage => 'core',
837
        required => 1,
838
        min_version => '1.17',
839
    },
840
    'Data::Session::Driver::Memcached' => {
841
        usage => 'core',
842
        required => 1,
843
        min_version => '1.17',
844
    },
845
    'Data::Session::Driver::mysql' => {
846
        usage => 'core',
847
        required => 1,
848
        min_version => '1.17',
849
    },
850
};
850
};
851
851
852
1;
852
1;
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 40-46 use MARC::Record; 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 C4::Members::Attributes qw(GetBorrowerAttributes);
44
use C4::Members::Attributes qw(GetBorrowerAttributes);
45
use Koha::AuthorisedValues;
45
use Koha::AuthorisedValues;
46
use Koha::Patron;
46
use Koha::Patron;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (-1 lines)
Lines 97-103 Administration: Link Here
97
              default: mysql
97
              default: mysql
98
              choices:
98
              choices:
99
                  mysql: in the MySQL database.
99
                  mysql: in the MySQL database.
100
                  Pg: in the PostgreSQL database (not supported).
101
                  tmp: as temporary files.
100
                  tmp: as temporary files.
102
                  memcached: in a memcached server.
101
                  memcached: in a memcached server.
103
        -
102
        -
(-)a/members/routing-lists.pl (-1 lines)
Lines 27-33 use C4::Members::Attributes qw(GetBorrowerAttributes); Link Here
27
use C4::Context;
27
use C4::Context;
28
use C4::Serials;
28
use C4::Serials;
29
use Koha::Patron::Images;
29
use Koha::Patron::Images;
30
use CGI::Session;
31
30
32
my $query = new CGI;
31
my $query = new CGI;
33
32
(-)a/tools/background-job-progress.pl (-2 lines)
Lines 23-29 use strict; Link Here
23
# standard or CPAN modules used
23
# standard or CPAN modules used
24
use IO::File;
24
use IO::File;
25
use CGI qw ( -utf8 );
25
use CGI qw ( -utf8 );
26
use CGI::Session;
27
use C4::Context;
26
use C4::Context;
28
use C4::Auth qw/check_cookie_auth/;
27
use C4::Auth qw/check_cookie_auth/;
29
use C4::BackgroundJob;
28
use C4::BackgroundJob;
30
- 

Return to bug 17427