Bug 19625: Enable Shibboleth auto-provisioning for Plack
authorMatthias Meusburger <matthias.meusburger@biblibre.com>
Wed, 15 Nov 2017 10:50:27 +0000 (10:50 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Tue, 9 Oct 2018 15:02:50 +0000 (15:02 +0000)
Test plan:
1. In $KOHA_CONF, check that //shibboleth/autocreate is set to 1
2. Find a user in Shibboleth that is not in Koha (or remove it from
   Koha)
3. Login with that user
4. Verify that the userid is not set correctly in Koha database
5. Apply the patch (restart starman)
6. Repeat steps 2 and 3
7. Verify that the userid is set correctly and the other
mapped fields if there are some

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Auth_with_shibboleth.pm

index 0ff0d25..24246d5 100644 (file)
@@ -125,7 +125,11 @@ sub _autocreate {
     my %borrower = ( $config->{matchpoint} => $match );
 
     while ( my ( $key, $entry ) = each %{$config->{'mapping'}} ) {
-        $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
+        if ( any { /(^psgi|^plack)/i } keys %ENV ) {
+            $borrower{$key} = ( $entry->{'is'} && $ENV{"HTTP_" . uc($entry->{'is'}) } ) || $entry->{'content'} || '';
+        } else {
+            $borrower{$key} = ( $entry->{'is'} && $ENV{ $entry->{'is'} } ) || $entry->{'content'} || '';
+        }
     }
 
     my $patron = Koha::Patron->new( \%borrower )->store;