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

(-)a/C4/Auth.pm (-12 / +20 lines)
Lines 154-159 sub get_template_and_user { Link Here
154
154
155
    my $in = shift;
155
    my $in = shift;
156
    my ( $user, $cookie, $sessionID, $flags );
156
    my ( $user, $cookie, $sessionID, $flags );
157
    $cookie = [];
157
158
158
    # Get shibboleth login attribute
159
    # Get shibboleth login attribute
159
    my $shib = C4::Context->config('useshibboleth') && shib_ok();
160
    my $shib = C4::Context->config('useshibboleth') && shib_ok();
Lines 243-249 sub get_template_and_user { Link Here
243
        if ($kick_out) {
244
        if ($kick_out) {
244
            $template = C4::Templates::gettemplate( 'opac-auth.tt', 'opac',
245
            $template = C4::Templates::gettemplate( 'opac-auth.tt', 'opac',
245
                $in->{query} );
246
                $in->{query} );
246
            $cookie = $in->{query}->cookie(
247
            push @$cookie, $in->{query}->cookie(
247
                -name     => 'CGISESSID',
248
                -name     => 'CGISESSID',
248
                -value    => '',
249
                -value    => '',
249
                -expires  => '',
250
                -expires  => '',
Lines 656-666 sub get_template_and_user { Link Here
656
        # what to do
657
        # what to do
657
        my $language = C4::Languages::getlanguage( $in->{'query'} );
658
        my $language = C4::Languages::getlanguage( $in->{'query'} );
658
        my $languagecookie = C4::Templates::getlanguagecookie( $in->{'query'}, $language );
659
        my $languagecookie = C4::Templates::getlanguagecookie( $in->{'query'}, $language );
659
        if ( ref $cookie eq 'ARRAY' ) {
660
        push @{$cookie}, $languagecookie;
660
            push @{$cookie}, $languagecookie;
661
        } else {
662
            $cookie = [ $cookie, $languagecookie ];
663
        }
664
    }
661
    }
665
662
666
    return ( $template, $borrowernumber, $cookie, $flags );
663
    return ( $template, $borrowernumber, $cookie, $flags );
Lines 810-815 sub _timeout_syspref { Link Here
810
    return $timeout;
807
    return $timeout;
811
}
808
}
812
809
810
sub clear_all_cookies {
811
    my ( $query ) = shift;
812
    my @cookies;
813
    for my $cookie_name ( $query->cookie ) {
814
        push @cookies, $query->cookie( -name => $cookie_name, -value => '', -expires => '', -HttpOnly => 1 );
815
    }
816
    return \@cookies;
817
}
818
813
sub checkauth {
819
sub checkauth {
814
    my $query = shift;
820
    my $query = shift;
815
821
Lines 846-851 sub checkauth { Link Here
846
    my $loggedin = 0;
852
    my $loggedin = 0;
847
    my %info;
853
    my %info;
848
    my ( $userid, $cookie, $sessionID, $flags );
854
    my ( $userid, $cookie, $sessionID, $flags );
855
    $cookie = [];
849
    my $logout = $query->param('logout.x');
856
    my $logout = $query->param('logout.x');
850
857
851
    my $anon_search_history;
858
    my $anon_search_history;
Lines 869-875 sub checkauth { Link Here
869
    if ( !$shib and defined( $ENV{'REMOTE_USER'} ) and $ENV{'REMOTE_USER'} ne '' and $userid = $ENV{'REMOTE_USER'} ) {
876
    if ( !$shib and defined( $ENV{'REMOTE_USER'} ) and $ENV{'REMOTE_USER'} ne '' and $userid = $ENV{'REMOTE_USER'} ) {
870
877
871
        # Using Basic Authentication, no cookies required
878
        # Using Basic Authentication, no cookies required
872
        $cookie = $query->cookie(
879
        push @$cookie, $query->cookie(
873
            -name     => 'CGISESSID',
880
            -name     => 'CGISESSID',
874
            -value    => '',
881
            -value    => '',
875
            -expires  => '',
882
            -expires  => '',
Lines 914-919 sub checkauth { Link Here
914
                my $shibSuccess = C4::Context->userenv->{'shibboleth'};
921
                my $shibSuccess = C4::Context->userenv->{'shibboleth'};
915
                $session->delete();
922
                $session->delete();
916
                $session->flush;
923
                $session->flush;
924
                $cookie = clear_all_cookies($query);
917
                C4::Context::_unset_userenv($sessionID);
925
                C4::Context::_unset_userenv($sessionID);
918
                $sessionID = undef;
926
                $sessionID = undef;
919
927
Lines 927-933 sub checkauth { Link Here
927
                }
935
                }
928
            } else {
936
            } else {
929
937
930
                $cookie = $query->cookie(
938
                push @$cookie, $query->cookie(
931
                    -name     => 'CGISESSID',
939
                    -name     => 'CGISESSID',
932
                    -value    => $session->id,
940
                    -value    => $session->id,
933
                    -HttpOnly => 1,
941
                    -HttpOnly => 1,
Lines 971-977 sub checkauth { Link Here
971
979
972
        $sessionID = $session->id;
980
        $sessionID = $session->id;
973
        C4::Context->_new_userenv($sessionID);
981
        C4::Context->_new_userenv($sessionID);
974
        $cookie = $query->cookie(
982
        push @$cookie, $query->cookie(
975
            -name     => 'CGISESSID',
983
            -name     => 'CGISESSID',
976
            -value    => $sessionID,
984
            -value    => $sessionID,
977
            -HttpOnly => 1,
985
            -HttpOnly => 1,
Lines 1171-1177 sub checkauth { Link Here
1171
                        $domain =~ s|\.\*||g;
1179
                        $domain =~ s|\.\*||g;
1172
                        if ( $ip !~ /^$domain/ ) {
1180
                        if ( $ip !~ /^$domain/ ) {
1173
                            $loggedin = 0;
1181
                            $loggedin = 0;
1174
                            $cookie = $query->cookie(
1182
                            push @$cookie, $query->cookie(
1175
                                -name     => 'CGISESSID',
1183
                                -name     => 'CGISESSID',
1176
                                -value    => '',
1184
                                -value    => '',
1177
                                -HttpOnly => 1,
1185
                                -HttpOnly => 1,
Lines 1259-1266 sub checkauth { Link Here
1259
    if ( $loggedin || $authnotrequired )
1267
    if ( $loggedin || $authnotrequired )
1260
    {
1268
    {
1261
        # successful login
1269
        # successful login
1262
        unless ($cookie) {
1270
        unless (@$cookie) {
1263
            $cookie = $query->cookie(
1271
            push @$cookie, $query->cookie(
1264
                -name     => 'CGISESSID',
1272
                -name     => 'CGISESSID',
1265
                -value    => '',
1273
                -value    => '',
1266
                -HttpOnly => 1,
1274
                -HttpOnly => 1,
(-)a/t/db_dependent/Auth.t (-2 / +1 lines)
Lines 229-235 subtest 'get_template_and_user' => sub { # Tests for the language URL paramete Link Here
229
            -HttpOnly => 1
229
            -HttpOnly => 1
230
        );
230
        );
231
231
232
        return ( $userid, $session_cookie, $sessionID, $flags );
232
        return ( $userid, [ $session_cookie ], $sessionID, $flags );
233
    }
233
    }
234
234
235
    # Mock checkauth, build the scenario
235
    # Mock checkauth, build the scenario
236
- 

Return to bug 29957