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

(-)a/C4/Auth.pm (-6 / +6 lines)
Lines 55-68 use Koha::CookieManager; Link Here
55
55
56
use vars qw($ldap $cas $caslogout);
56
use vars qw($ldap $cas $caslogout);
57
our (@ISA, @EXPORT_OK);
57
our (@ISA, @EXPORT_OK);
58
BEGIN {
59
    sub psgi_env { any { /^psgi\./ } keys %ENV }
60
58
61
    sub safe_exit {
59
sub safe_exit {
62
        if   (psgi_env) { die 'psgi:exit' }
60
    if   (C4::Context::psgi_env) { die 'psgi:exit' }
63
        else            { exit }
61
    else            { exit }
64
    }
62
}
65
63
64
65
BEGIN {
66
    C4::Context->set_remote_address;
66
    C4::Context->set_remote_address;
67
67
68
    require Exporter;
68
    require Exporter;
(-)a/C4/Auth_with_shibboleth.pm (-3 / +3 lines)
Lines 81-87 sub get_login_shib { Link Here
81
81
82
    my $matchAttribute = $config->{mapping}->{ $config->{matchpoint} }->{is};
82
    my $matchAttribute = $config->{mapping}->{ $config->{matchpoint} }->{is};
83
83
84
    if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
84
    if ( C4::Context::psgi_env ) {
85
      return $ENV{"HTTP_".uc($matchAttribute)} || '';
85
      return $ENV{"HTTP_".uc($matchAttribute)} || '';
86
    } else {
86
    } else {
87
      return $ENV{$matchAttribute} || '';
87
      return $ENV{$matchAttribute} || '';
Lines 126-132 sub _autocreate { Link Here
126
    my %borrower = ( $config->{matchpoint} => $match );
126
    my %borrower = ( $config->{matchpoint} => $match );
127
127
128
    while ( my ( $key, $entry ) = each %{$config->{'mapping'}} ) {
128
    while ( my ( $key, $entry ) = each %{$config->{'mapping'}} ) {
129
        if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
129
        if ( C4::Context::psgi_env ) {
130
            $borrower{$key} = ( $entry->{'is'} && $ENV{"HTTP_" . uc($entry->{'is'}) } ) || $entry->{'content'} || '';
130
            $borrower{$key} = ( $entry->{'is'} && $ENV{"HTTP_" . uc($entry->{'is'}) } ) || $entry->{'content'} || '';
131
        } else {
131
        } else {
132
            $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
132
            $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
Lines 144-150 sub _sync { Link Here
144
    my %borrower;
144
    my %borrower;
145
    $borrower{'borrowernumber'} = $borrowernumber;
145
    $borrower{'borrowernumber'} = $borrowernumber;
146
    while ( my ( $key, $entry ) = each %{$config->{'mapping'}} ) {
146
    while ( my ( $key, $entry ) = each %{$config->{'mapping'}} ) {
147
        if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
147
        if ( C4::Context::psgi_env ) {
148
            $borrower{$key} = ( $entry->{'is'} && $ENV{"HTTP_" . uc($entry->{'is'}) } ) || $entry->{'content'} || '';
148
            $borrower{$key} = ( $entry->{'is'} && $ENV{"HTTP_" . uc($entry->{'is'}) } ) || $entry->{'content'} || '';
149
        } else {
149
        } else {
150
            $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
150
            $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
(-)a/C4/Context.pm (-10 / +4 lines)
Lines 999-1019 sub needs_install { Link Here
999
    return ($self->preference('Version')) ? 0 : 1;
999
    return ($self->preference('Version')) ? 0 : 1;
1000
}
1000
}
1001
1001
1002
=head3 is_psgi_or_plack
1002
=head3 psgi_env
1003
1003
1004
is_psgi_or_plack returns true if there is an environmental variable
1004
psgi_env returns true if there is an environmental variable
1005
prefixed with "psgi" or "plack". This is useful for detecting whether
1005
prefixed with "psgi" or "plack". This is useful for detecting whether
1006
this is a PSGI app or a CGI app, and implementing code as appropriate.
1006
this is a PSGI app or a CGI app, and implementing code as appropriate.
1007
1007
1008
=cut
1008
=cut
1009
1009
1010
sub is_psgi_or_plack {
1010
sub psgi_env { any { /(^psgi\.|^plack\.)/i } keys %ENV };
1011
    my $is_psgi_or_plack = 0;
1012
    if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
1013
        $is_psgi_or_plack = 1;
1014
    }
1015
    return $is_psgi_or_plack;
1016
}
1017
1011
1018
=head3 is_internal_PSGI_request
1012
=head3 is_internal_PSGI_request
1019
1013
Lines 1026-1032 app Link Here
1026
#NOTE: This is not a very robust method but it's the best we have so far
1020
#NOTE: This is not a very robust method but it's the best we have so far
1027
sub is_internal_PSGI_request {
1021
sub is_internal_PSGI_request {
1028
    my $is_internal = 0;
1022
    my $is_internal = 0;
1029
    if ( (__PACKAGE__->is_psgi_or_plack) && ( $ENV{REQUEST_URI} !~ /^(\/intranet|\/opac)/ ) ){
1023
    if ( (__PACKAGE__->psgi_env) && ( $ENV{REQUEST_URI} !~ /^(\/intranet|\/opac)/ ) ){
1030
        $is_internal = 1;
1024
        $is_internal = 1;
1031
    }
1025
    }
1032
    return $is_internal;
1026
    return $is_internal;
(-)a/Koha/AuthUtils.pm (-3 / +1 lines)
Lines 208-216 outside this context. Link Here
208
=cut
208
=cut
209
209
210
sub get_script_name {
210
sub get_script_name {
211
    # This is the method about.pl uses to detect Plack; now that two places use it, it MUST be
211
    if ( ( C4::Context::psgi_env ) && $ENV{SCRIPT_NAME} =~ m,^/(intranet|opac)(.*), ) {
212
    # right.
213
    if ( ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) && $ENV{SCRIPT_NAME} =~ m,^/(intranet|opac)(.*), ) {
214
        return '/cgi-bin/koha' . $2;
212
        return '/cgi-bin/koha' . $2;
215
    } else {
213
    } else {
216
        return $ENV{SCRIPT_NAME};
214
        return $ENV{SCRIPT_NAME};
(-)a/about.pl (-2 / +1 lines)
Lines 125-131 if ($^O ne 'VMS') { Link Here
125
my $zebraVersion = `zebraidx -V`;
125
my $zebraVersion = `zebraidx -V`;
126
126
127
# Check running PSGI env
127
# Check running PSGI env
128
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
128
if ( C4::Context::psgi_env ) {
129
    $template->param(
129
    $template->param(
130
        is_psgi => 1,
130
        is_psgi => 1,
131
        psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
131
        psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
132
- 

Return to bug 29744