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

(-)a/C4/Auth.pm (-6 / +6 lines)
Lines 53-66 use C4::Log qw( logaction ); Link Here
53
53
54
use vars qw($ldap $cas $caslogout);
54
use vars qw($ldap $cas $caslogout);
55
our (@ISA, @EXPORT_OK);
55
our (@ISA, @EXPORT_OK);
56
BEGIN {
57
    sub psgi_env { any { /^psgi\./ } keys %ENV }
58
56
59
    sub safe_exit {
57
sub safe_exit {
60
        if   (psgi_env) { die 'psgi:exit' }
58
    if   (C4::Context::psgi_env) { die 'psgi:exit' }
61
        else            { exit }
59
    else            { exit }
62
    }
60
}
63
61
62
63
BEGIN {
64
    C4::Context->set_remote_address;
64
    C4::Context->set_remote_address;
65
65
66
    require Exporter;
66
    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 979-999 sub needs_install { Link Here
979
    return ($self->preference('Version')) ? 0 : 1;
979
    return ($self->preference('Version')) ? 0 : 1;
980
}
980
}
981
981
982
=head3 is_psgi_or_plack
982
=head3 psgi_env
983
983
984
is_psgi_or_plack returns true if there is an environmental variable
984
psgi_env returns true if there is an environmental variable
985
prefixed with "psgi" or "plack". This is useful for detecting whether
985
prefixed with "psgi" or "plack". This is useful for detecting whether
986
this is a PSGI app or a CGI app, and implementing code as appropriate.
986
this is a PSGI app or a CGI app, and implementing code as appropriate.
987
987
988
=cut
988
=cut
989
989
990
sub is_psgi_or_plack {
990
sub psgi_env { any { /(^psgi\.|^plack\.)/i } keys %ENV };
991
    my $is_psgi_or_plack = 0;
992
    if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
993
        $is_psgi_or_plack = 1;
994
    }
995
    return $is_psgi_or_plack;
996
}
997
991
998
=head3 is_internal_PSGI_request
992
=head3 is_internal_PSGI_request
999
993
Lines 1006-1012 app Link Here
1006
#NOTE: This is not a very robust method but it's the best we have so far
1000
#NOTE: This is not a very robust method but it's the best we have so far
1007
sub is_internal_PSGI_request {
1001
sub is_internal_PSGI_request {
1008
    my $is_internal = 0;
1002
    my $is_internal = 0;
1009
    if ( (__PACKAGE__->is_psgi_or_plack) && ( $ENV{REQUEST_URI} !~ /^(\/intranet|\/opac)/ ) ){
1003
    if ( (__PACKAGE__->psgi_env) && ( $ENV{REQUEST_URI} !~ /^(\/intranet|\/opac)/ ) ){
1010
        $is_internal = 1;
1004
        $is_internal = 1;
1011
    }
1005
    }
1012
    return $is_internal;
1006
    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 123-129 if ($^O ne 'VMS') { Link Here
123
my $zebraVersion = `zebraidx -V`;
123
my $zebraVersion = `zebraidx -V`;
124
124
125
# Check running PSGI env
125
# Check running PSGI env
126
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
126
if ( C4::Context::psgi_env ) {
127
    $template->param(
127
    $template->param(
128
        is_psgi => 1,
128
        is_psgi => 1,
129
        psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
129
        psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
130
- 

Return to bug 29744