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

(-)a/C4/Auth.pm (-21 / +3 lines)
Lines 32-38 use C4::Languages; Link Here
32
use C4::Branch;       # GetBranches
32
use C4::Branch;       # GetBranches
33
use C4::Search::History;
33
use C4::Search::History;
34
use Koha;
34
use Koha;
35
use Koha::AuthUtils qw(hash_password);
35
use Koha::AuthUtils qw(get_script_name hash_password);
36
use Koha::LibraryCategories;
36
use Koha::LibraryCategories;
37
use Koha::Libraries;
37
use Koha::Libraries;
38
use POSIX qw/strftime/;
38
use POSIX qw/strftime/;
Lines 194-200 sub get_template_and_user { Link Here
194
194
195
            $template->param(
195
            $template->param(
196
                loginprompt => 1,
196
                loginprompt => 1,
197
                script_name => _get_script_name(),
197
                script_name => get_script_name(),
198
            );
198
            );
199
            print $in->{query}->header(
199
            print $in->{query}->header(
200
                {   type              => 'text/html',
200
                {   type              => 'text/html',
Lines 1211-1217 sub checkauth { Link Here
1211
        opaclayoutstylesheet                  => C4::Context->preference("opaclayoutstylesheet"),
1211
        opaclayoutstylesheet                  => C4::Context->preference("opaclayoutstylesheet"),
1212
        login                                 => 1,
1212
        login                                 => 1,
1213
        INPUTS                                => \@inputs,
1213
        INPUTS                                => \@inputs,
1214
        script_name                           => _get_script_name(),
1214
        script_name                           => get_script_name(),
1215
        casAuthentication                     => C4::Context->preference("casAuthentication"),
1215
        casAuthentication                     => C4::Context->preference("casAuthentication"),
1216
        shibbolethAuthentication              => $shib,
1216
        shibbolethAuthentication              => $shib,
1217
        SessionRestrictionByIP                => C4::Context->preference("SessionRestrictionByIP"),
1217
        SessionRestrictionByIP                => C4::Context->preference("SessionRestrictionByIP"),
Lines 2050-2073 sub getborrowernumber { Link Here
2050
    return 0;
2050
    return 0;
2051
}
2051
}
2052
2052
2053
=head2 _get_script_name
2054
2055
This returns the correct script name, for use in redirecting back to the correct page after showing
2056
the login screen. It depends on details of the package Plack configuration, and should not be used
2057
outside this context.
2058
2059
=cut
2060
2061
sub _get_script_name {
2062
    # This is the method about.pl uses to detect Plack; now that two places use it, it MUST be
2063
    # right.
2064
    if ( ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) && $ENV{SCRIPT_NAME} =~ m,^/(intranet|opac)(.*), ) {
2065
        return '/cgi-bin/koha' . $2;
2066
    } else {
2067
        return $ENV{SCRIPT_NAME};
2068
    }
2069
}
2070
2071
END { }    # module clean-up code here (global destructor)
2053
END { }    # module clean-up code here (global destructor)
2072
1;
2054
1;
2073
__END__
2055
__END__
(-)a/C4/Auth_with_cas.pm (-1 / +2 lines)
Lines 22-27 use warnings; Link Here
22
22
23
use C4::Debug;
23
use C4::Debug;
24
use C4::Context;
24
use C4::Context;
25
use Koha::AuthUtils qw(get_script_name);
25
use Authen::CAS::Client;
26
use Authen::CAS::Client;
26
use CGI qw ( -utf8 );
27
use CGI qw ( -utf8 );
27
use FindBin;
28
use FindBin;
Lines 203-209 sub _url_with_get_params { Link Here
203
    my $type = shift;
204
    my $type = shift;
204
205
205
    my $uri_base_part = ($type eq 'opac') ?
206
    my $uri_base_part = ($type eq 'opac') ?
206
                        C4::Context->preference('OPACBaseURL') . $query->script_name():
207
                        C4::Context->preference('OPACBaseURL') . get_script_name() :
207
                        C4::Context->preference('staffClientBaseURL');
208
                        C4::Context->preference('staffClientBaseURL');
208
209
209
    my $uri_params_part = '';
210
    my $uri_params_part = '';
(-)a/C4/Auth_with_shibboleth.pm (-1 / +2 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use C4::Debug;
22
use C4::Debug;
23
use C4::Context;
23
use C4::Context;
24
use Koha::AuthUtils qw(get_script_name);
24
use Koha::Database;
25
use Koha::Database;
25
use Carp;
26
use Carp;
26
use CGI;
27
use CGI;
Lines 57-63 sub logout_shib { Link Here
57
sub login_shib_url {
58
sub login_shib_url {
58
    my ($query) = @_;
59
    my ($query) = @_;
59
60
60
    my $param = _get_uri() . $query->script_name();
61
    my $param = _get_uri() . get_script_name();
61
    if ( $query->query_string() ) {
62
    if ( $query->query_string() ) {
62
        $param = $param . '%3F' . $query->query_string();
63
        $param = $param . '%3F' . $query->query_string();
63
    }
64
    }
(-)a/Koha/AuthUtils.pm (-2 / +21 lines)
Lines 21-30 use Modern::Perl; Link Here
21
use Crypt::Eksblowfish::Bcrypt qw(bcrypt en_base64);
21
use Crypt::Eksblowfish::Bcrypt qw(bcrypt en_base64);
22
use Encode qw( encode is_utf8 );
22
use Encode qw( encode is_utf8 );
23
use Fcntl qw/O_RDONLY/; # O_RDONLY is used in generate_salt
23
use Fcntl qw/O_RDONLY/; # O_RDONLY is used in generate_salt
24
use List::MoreUtils qw/ any /;
24
25
25
use base 'Exporter';
26
use base 'Exporter';
26
27
27
our @EXPORT_OK   = qw(hash_password);
28
our @EXPORT_OK   = qw(hash_password get_script_name);
28
29
29
=head1 NAME
30
=head1 NAME
30
31
Lines 132-137 sub generate_salt { Link Here
132
    close SOURCE;
133
    close SOURCE;
133
    return $string;
134
    return $string;
134
}
135
}
136
137
=head2 get_script_name
138
139
This returns the correct script name, for use in redirecting back to the correct page after showing
140
the login screen. It depends on details of the package Plack configuration, and should not be used
141
outside this context.
142
143
=cut
144
145
sub get_script_name {
146
    # This is the method about.pl uses to detect Plack; now that two places use it, it MUST be
147
    # right.
148
    if ( ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) && $ENV{SCRIPT_NAME} =~ m,^/(intranet|opac)(.*), ) {
149
        return '/cgi-bin/koha' . $2;
150
    } else {
151
        return $ENV{SCRIPT_NAME};
152
    }
153
}
154
135
1;
155
1;
136
156
137
__END__
157
__END__
138
- 

Return to bug 16818