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

(-)a/C4/Auth.pm (-12 / +20 lines)
Lines 153-158 sub get_template_and_user { Link Here
153
153
154
    my $in = shift;
154
    my $in = shift;
155
    my ( $user, $cookie, $sessionID, $flags );
155
    my ( $user, $cookie, $sessionID, $flags );
156
    $cookie = [];
156
157
157
    # Get shibboleth login attribute
158
    # Get shibboleth login attribute
158
    my $shib = C4::Context->config('useshibboleth') && shib_ok();
159
    my $shib = C4::Context->config('useshibboleth') && shib_ok();
Lines 242-248 sub get_template_and_user { Link Here
242
        if ($kick_out) {
243
        if ($kick_out) {
243
            $template = C4::Templates::gettemplate( 'opac-auth.tt', 'opac',
244
            $template = C4::Templates::gettemplate( 'opac-auth.tt', 'opac',
244
                $in->{query} );
245
                $in->{query} );
245
            $cookie = $in->{query}->cookie(
246
            push @$cookie, $in->{query}->cookie(
246
                -name     => 'CGISESSID',
247
                -name     => 'CGISESSID',
247
                -value    => '',
248
                -value    => '',
248
                -expires  => '',
249
                -expires  => '',
Lines 654-664 sub get_template_and_user { Link Here
654
        # what to do
655
        # what to do
655
        my $language = C4::Languages::getlanguage( $in->{'query'} );
656
        my $language = C4::Languages::getlanguage( $in->{'query'} );
656
        my $languagecookie = C4::Templates::getlanguagecookie( $in->{'query'}, $language );
657
        my $languagecookie = C4::Templates::getlanguagecookie( $in->{'query'}, $language );
657
        if ( ref $cookie eq 'ARRAY' ) {
658
        push @{$cookie}, $languagecookie;
658
            push @{$cookie}, $languagecookie;
659
        } else {
660
            $cookie = [ $cookie, $languagecookie ];
661
        }
662
    }
659
    }
663
660
664
    return ( $template, $borrowernumber, $cookie, $flags );
661
    return ( $template, $borrowernumber, $cookie, $flags );
Lines 808-813 sub _timeout_syspref { Link Here
808
    return $timeout;
805
    return $timeout;
809
}
806
}
810
807
808
sub clear_all_cookies {
809
    my ( $query ) = shift;
810
    my @cookies;
811
    for my $cookie_name ( $query->cookie ) {
812
        push @cookies, $query->cookie( -name => $cookie_name, -value => '', -expires => '', -HttpOnly => 1 );
813
    }
814
    return \@cookies;
815
}
816
811
sub checkauth {
817
sub checkauth {
812
    my $query = shift;
818
    my $query = shift;
813
819
Lines 844-849 sub checkauth { Link Here
844
    my $loggedin = 0;
850
    my $loggedin = 0;
845
    my %info;
851
    my %info;
846
    my ( $userid, $cookie, $sessionID, $flags );
852
    my ( $userid, $cookie, $sessionID, $flags );
853
    $cookie = [];
847
    my $logout = $query->param('logout.x');
854
    my $logout = $query->param('logout.x');
848
855
849
    my $anon_search_history;
856
    my $anon_search_history;
Lines 867-873 sub checkauth { Link Here
867
    if ( !$shib and defined( $ENV{'REMOTE_USER'} ) and $ENV{'REMOTE_USER'} ne '' and $userid = $ENV{'REMOTE_USER'} ) {
874
    if ( !$shib and defined( $ENV{'REMOTE_USER'} ) and $ENV{'REMOTE_USER'} ne '' and $userid = $ENV{'REMOTE_USER'} ) {
868
875
869
        # Using Basic Authentication, no cookies required
876
        # Using Basic Authentication, no cookies required
870
        $cookie = $query->cookie(
877
        push @$cookie, $query->cookie(
871
            -name     => 'CGISESSID',
878
            -name     => 'CGISESSID',
872
            -value    => '',
879
            -value    => '',
873
            -expires  => '',
880
            -expires  => '',
Lines 910-915 sub checkauth { Link Here
910
                my $shibSuccess = C4::Context->userenv->{'shibboleth'};
917
                my $shibSuccess = C4::Context->userenv->{'shibboleth'};
911
                $session->delete();
918
                $session->delete();
912
                $session->flush;
919
                $session->flush;
920
                $cookie = clear_all_cookies($query);
913
                C4::Context->_unset_userenv($sessionID);
921
                C4::Context->_unset_userenv($sessionID);
914
922
915
                if ($cas and $caslogout) {
923
                if ($cas and $caslogout) {
Lines 922-928 sub checkauth { Link Here
922
                }
930
                }
923
            } else {
931
            } else {
924
932
925
                $cookie = $query->cookie(
933
                push @$cookie, $query->cookie(
926
                    -name     => 'CGISESSID',
934
                    -name     => 'CGISESSID',
927
                    -value    => $session->id,
935
                    -value    => $session->id,
928
                    -HttpOnly => 1,
936
                    -HttpOnly => 1,
Lines 968-974 sub checkauth { Link Here
968
976
969
        $sessionID = $session->id;
977
        $sessionID = $session->id;
970
        C4::Context->_new_userenv($sessionID);
978
        C4::Context->_new_userenv($sessionID);
971
        $cookie = $query->cookie(
979
        push @$cookie, $query->cookie(
972
            -name     => 'CGISESSID',
980
            -name     => 'CGISESSID',
973
            -value    => $sessionID,
981
            -value    => $sessionID,
974
            -HttpOnly => 1,
982
            -HttpOnly => 1,
Lines 1168-1174 sub checkauth { Link Here
1168
                        $domain =~ s|\.\*||g;
1176
                        $domain =~ s|\.\*||g;
1169
                        if ( $ip !~ /^$domain/ ) {
1177
                        if ( $ip !~ /^$domain/ ) {
1170
                            $loggedin = 0;
1178
                            $loggedin = 0;
1171
                            $cookie = $query->cookie(
1179
                            push @$cookie, $query->cookie(
1172
                                -name     => 'CGISESSID',
1180
                                -name     => 'CGISESSID',
1173
                                -value    => '',
1181
                                -value    => '',
1174
                                -HttpOnly => 1,
1182
                                -HttpOnly => 1,
Lines 1255-1262 sub checkauth { Link Here
1255
    if ( $loggedin || $authnotrequired )
1263
    if ( $loggedin || $authnotrequired )
1256
    {
1264
    {
1257
        # successful login
1265
        # successful login
1258
        unless ($cookie) {
1266
        unless (@$cookie) {
1259
            $cookie = $query->cookie(
1267
            push @$cookie, $query->cookie(
1260
                -name     => 'CGISESSID',
1268
                -name     => 'CGISESSID',
1261
                -value    => '',
1269
                -value    => '',
1262
                -HttpOnly => 1,
1270
                -HttpOnly => 1,
(-)a/t/db_dependent/Auth.t (-2 / +1 lines)
Lines 228-234 subtest 'checkpw lockout tests' => sub { Link Here
228
            -HttpOnly => 1
228
            -HttpOnly => 1
229
        );
229
        );
230
230
231
        return ( $userid, $session_cookie, $sessionID, $flags );
231
        return ( $userid, [ $session_cookie ], $sessionID, $flags );
232
    }
232
    }
233
233
234
    # Mock checkauth, build the scenario
234
    # Mock checkauth, build the scenario
235
- 

Return to bug 29957